RtThemesSupport

RT16 V 2.3 content generator wpml banner fix rttheme16

Feb 7th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 19.18 KB | None | 0 0
  1.     <?php
  2.     global $UserSidebarIDs,$selectedTemplateID;  
  3.    
  4.     $cotent_generator = true;  
  5.    
  6.     #
  7.     #   Get all templates
  8.     #
  9.     $savedTemplates = get_option('rt_page_layouts');
  10.        
  11.     #
  12.     #   Template to use
  13.     #
  14.     if($selectedTemplateID && isset($savedTemplates->templates[$selectedTemplateID])){
  15.         #
  16.         #   Use user selected template
  17.         #  
  18.         $selectedTemplate = $savedTemplates->templates[$selectedTemplateID];
  19.     }else{
  20.         #
  21.         #   no template created - we create default one according sidebars
  22.         #
  23.         $selectedTemplate = new stdClass;
  24.         $selectedTemplate->templateID                = 0;
  25.         $selectedTemplate->templateName              = "Default Template";
  26.         $selectedTemplate->sidebar                   = $sidebar;
  27.         $selectedTemplate->lineup                    = "on";
  28.         @$selectedTemplate->contents[0]->group_id     = 1;
  29.         @$selectedTemplate->contents[0]->content_type = "default_content";
  30.         @$selectedTemplate->contents[0]->layout       = "one";
  31.         @$selectedTemplate->contents[0]->heading      = "on";
  32.     }
  33.  
  34.     #
  35.     #   Temaplate Items
  36.     #                              
  37.     $selectedTemplate_contents = $selectedTemplate->contents;
  38.    
  39.     #
  40.     #   Sidebar
  41.     #
  42.     $sidebar=$selectedTemplate->sidebar ? $selectedTemplate->sidebar : str_replace("fullwidth","full",get_page_layout());
  43.    
  44.     #
  45.     #   Content Width
  46.     #
  47.     $content_width = ($sidebar=="full") ? 960 : 710;
  48.    
  49.     #
  50.     #   Call the holder's 1st part
  51.     #
  52.     sub_page_layout("subheader",$sidebar);
  53.  
  54.        
  55.     #
  56.     #   Layout grid values
  57.     #
  58.     $layout_values  = array("four-five"=>48,"three-four"=>45,"two-three"=>40,"five"=>12,"four"=>15,"three"=>20,"two"=>30,"one"=>60);
  59.    
  60.    
  61.     #
  62.     #   Prepare counting boxes
  63.     #      
  64.     $boxNumber = 1;
  65.     $box_counter = 1;
  66.     $total_width = 0;
  67.     $emptyContent = "";
  68.     $reset_row_count = 0;
  69.     $fixedRows = 0;
  70.      
  71.     #
  72.     #   Do for each content that has been added for this template
  73.     #
  74.     if($selectedTemplate_contents){
  75.     foreach($selectedTemplate_contents as $templateID => $template){   
  76.    
  77.    
  78.             #
  79.             #   Box Layout
  80.             #
  81.             if($template->layout){
  82.                 $this_item_layout=$template->layout;
  83.             }
  84.            
  85.             #
  86.             #   Next item box width
  87.             #
  88.             if(isset($selectedTemplate_contents[$templateID+1]->layout)){
  89.                 $next_item_layout = $selectedTemplate_contents[$templateID+1]->layout;
  90.                
  91.                 if(empty($next_item_layout)) {
  92.                     $next_item_layout  = $template->layout;  
  93.                 }
  94.             }
  95.                  
  96.                
  97.             #
  98.             #   this column width   - pixel
  99.             #
  100.             $this_column_width_pixel =  intval ($content_width / (60/$layout_values[$this_item_layout]) );
  101.            
  102.            
  103.             #
  104.             #   first and last box of each row
  105.             #      
  106.             $next_item_width = (isset($next_item_layout)) ? $layout_values[$next_item_layout] : "";
  107.             $total_width     = ($total_width==0) ? $layout_values[$this_item_layout] + $next_item_width : $total_width + $next_item_width;         
  108.             $firstBox        = ($box_counter ==1) ? "first" : false;
  109.             $lastBox         = ($total_width > 60) ? "last" : false;
  110.             $box_counter     = ($total_width > 60) ? $box_counter = 1 : $box_counter+1 ;
  111.             $reset_row_count = ($box_counter == 1) ? 0 : $reset_row_count;
  112.             $total_width     = ($total_width>60) ? 0 : $total_width;
  113.        
  114.                
  115.             #
  116.             #   reset the row
  117.             #      
  118.             $reset = ($lastBox) ? true : false;
  119.  
  120.                     #
  121.                     #   Call Slider
  122.                     #
  123.                     if($template->content_type=="slider_box"){
  124.                        
  125.                         echo    ($template->layout=="one") ? "" :'<div class="template_builder box '.$template->layout.' '.$firstBox.'  '.$lastBox.'">';
  126.                        
  127.                         $slides=array(
  128.                             'post_type'           => 'slider',
  129.                             'post_status'         => 'publish',
  130.                             'ignore_sticky_posts' => 1,
  131.                             'showposts'           => 1000,
  132.                             'cat'                 => -0,
  133.                             'post__in'            => $template->content_id,
  134.                             'orderby'             => $template->list_orderby,
  135.                             'order'               => $template->list_order                         
  136.                         );
  137.                        
  138.                         $slider_script         =  $template->slider_script;
  139.                         $rttheme_slider_height =  $template->slider_height;
  140.                         $rttheme_slider_width  =  $sidebar=="full" ? 940 : 690;
  141.                         $crop_slider_images    = ($template->image_crop) ? true : false;
  142.                         $resize_slider_images  =  $template->image_resize;
  143.                         $slider_effect         =  $template->slider_effect;
  144.                         $slider_timeout        =  $template->slider_timeout;
  145.                         $slider_buttons        =  $template->slider_buttons;
  146.                         $group_id              =  $template->group_id;
  147.                        
  148.                             if($slider_script=="cycle"){
  149.                                 get_template_part( 'cycle-slider', 'home_slider' );
  150.                             }elseif($slider_script=="nivo"){
  151.                                 get_template_part( 'nivo-slider', 'home_slider' );
  152.                             }else{
  153.                                 get_template_part( 'accordion-slider', 'home_slider' );
  154.                             }
  155.                        
  156.                         echo    ($template->layout=="one") ? "" : '</div>';
  157.                     }
  158.  
  159.                     #
  160.                     #   Banner Text
  161.                     #
  162.                     if($template->content_type=="banner_box"){
  163.                         $group_id              =  $template->group_id;             
  164.                                        
  165.                         echo $sidebar=="full" ? '</div>' : '';
  166.                        
  167.                         $template->button_color = isset($template->button_color) ? $template->button_color : "";
  168.                         $template->button_link = isset($template->button_link) ? $template->button_link : "";
  169.                         $template->button_text = isset($template->button_text) ? $template->button_text : "";
  170.                         $template->button_size = isset($template->button_size) ? $template->button_size : "";
  171.                        
  172.                         echo'   <div class="border-line margin-b10"></div>  ';
  173.                         echo'   <div class="row color1">    ';
  174.                         echo'   <div class="template_builder banner clearfix">  ';
  175.                                
  176.                         echo ($template->button_link && $template->button_text) ? '<a href="'.wpml_t( THEMESLUG , 'Button Link for Banner '.$selectedTemplate->templateID.$group_id, $template->button_link ).'" class="button '.$template->button_color.' '.$template->button_size.' alignright">'.wpml_t( THEMESLUG , 'Button Text for Banner '.$selectedTemplate->templateID.$group_id, $template->button_text ).'</a>' : '';                       
  177.                         echo ($template->button_link && $template->button_text) ? '<p class="featured_text text_shadow withbutton">': '<p class="featured_text text_shadow">';
  178.                         echo        stripslashes(wpml_t( THEMESLUG , 'Text for Banner '.$selectedTemplate->templateID.$group_id, $template->text ));
  179.                         echo'   </p>    ';                                 
  180.                        
  181.                         echo'   </div>  ';
  182.                         echo'   </div>  ';
  183.                         echo'   <div class="border-line margin-t10"></div>  ';
  184.                        
  185.                        
  186.                         echo $sidebar=="full" ? '<div class="content fullwidth clearfix">' : '' ;
  187.                        
  188.                     }
  189.  
  190.                     #
  191.                     #   Default Content
  192.                     #
  193.                     if($template->content_type=="default_content"){
  194.                         $heading    = $template->heading;
  195.                        
  196.                         if(!is_front_page()){
  197.                                 if(is_page())       get_template_part( 'page_content', 'page_content_file' );
  198.                                 if(is_single())     get_template_part( 'post_content', 'post_content_file' );
  199.                         }else{
  200.                                 $reset="";
  201.                         }
  202.                        
  203.                     }
  204.                    
  205.                     #
  206.                     #   Call Sidebar Box
  207.                     #
  208.                     if($template->content_type=="sidebar_box"){
  209.                        
  210.                         $box_width  = $template->widget_box_width;
  211.                         $sidebarID  = $template->sidebar_id;
  212.                         $layout        = $template->layout;
  213.                         $widget_border  = isset($template->widget_border) ? "border white" : "";
  214.                         $home_contents_count=0;//reset widget count
  215.                         $widget_num=false;//reset widget count
  216.                        
  217.                         echo    ($template->layout=="one") ? "" :'<div class="template_builder box '.$widget_border.' '.$template->layout.' '.$firstBox.'  '.$lastBox.'">';
  218.                         echo ($widget_border) ? '<div class="padding-div">' : '' ;
  219.                            
  220.                             add_filter('dynamic_sidebar_params', array("RT_Create_Sidebars",'home_page_layout_class'));                
  221.                             dynamic_sidebar($template->sidebar_id);
  222.                        
  223.                         echo ($widget_border) ? '</div>' : '' ;
  224.                         echo    ($template->layout=="one") ? "" : '</div>';
  225.                     }
  226.  
  227.                     #
  228.                     #   Call All Content Boxes
  229.                     #
  230.                     if($template->content_type=="all_content_boxes"){
  231.                         $home_page        = array(  'post_type'=> 'home_page', 'post_status'=> 'publish', 'showposts' => -1, 'cat' => -0, 'post__in'  => $template->content_id, 'orderby' => $template->list_orderby, 'order' => $template->list_order);
  232.                         $layout           = $template->layout;
  233.                         $item_width       = $template->item_width; //item width
  234.                         $box_border       = isset($template->box_border) ? "border" : "" ; //border of the container box
  235.                         $container_border = ($layout != "one" && $box_border) ? "border" : "";
  236.                        
  237.                         echo    ($template->layout=="one") ? "" :'<div class="template_builder box '.$container_border.' '.$template->layout.' '.$firstBox.'  '.$lastBox.'">';
  238.                         echo ($container_border) ? '<div class="padding-div">' : '' ;
  239.                                    
  240.                         get_template_part( 'home_content_loop', 'home_page' );
  241.                        
  242.                         echo ($container_border) ? '</div>' : '' ;
  243.                         echo    ($template->layout=="one") ? "" : '</div>';                    
  244.                     }
  245.                    
  246.                     #
  247.                     #   Call a Content Box
  248.                     #
  249.                     if($template->content_type=="home_page_box"){
  250.                         $home_page  = array(  'post_type'=> 'home_page',   'post_status'=> 'publish',   'showposts' => 1,   'cat' => -0,  'p'  => $template->content_id);
  251.                         $layout     = $template->layout;
  252.                         get_template_part( 'home_content_loop', 'home_page' );
  253.                     }
  254.        
  255.    
  256.                     #
  257.                     #   Call Portfolio Box
  258.                     #
  259.                     if($template->content_type=="portfolio_box"){              
  260.                                
  261.                        
  262.                         $item_width = $template->item_width; //item width
  263.                         $box_border = isset($template->box_border) ? "border" : "" ; //border of the container box
  264.                         $layout     = $template->layout;
  265.                        
  266.                         echo    ($layout=="one") ? "" :'<div class="template_builder box '.$box_border.' '.$layout.' '.$firstBox.'  '.$lastBox.'">';
  267.                         echo ($box_border) ? '<div class="padding-div">' : '' ;
  268.                    
  269.                                 //page
  270.                                 if($template->pagination){
  271.                                     if (get_query_var('paged') ) {$paged = get_query_var('paged');} elseif ( get_query_var('page') ) {$paged = get_query_var('page');} else {$paged = 1;}
  272.                                 }else{
  273.                                     $paged=0;
  274.                                 }
  275.  
  276.                                 $template->categories = isset($template->categories) ? $template->categories : "";
  277.    
  278.                                 //general query
  279.                                 $args=array(
  280.                                     'post_status'    => 'publish',
  281.                                     'post_type'      => 'portfolio',
  282.                                     'orderby'        => $template->portf_list_orderby,
  283.                                     'order'          => $template->portf_list_order,
  284.                                     'posts_per_page' => $template->item_per_page,
  285.                                     'paged'          => $paged,
  286.                          
  287.                                     'tax_query' => array(
  288.                                         array(
  289.                                             'taxonomy' =>   'portfolio_categories',
  290.                                             'field'    =>   'id',
  291.                                             'terms'    =>    $template->categories,
  292.                                             'operator' =>   ($template->categories)  ? "IN" : "OR"
  293.                                         )
  294.                                     ),                                                                     
  295.                                 );
  296.                                  
  297.                                
  298.                                 get_template_part( 'portfolio_loop', 'portfolio_categories' );
  299.                        
  300.                         echo ($box_border) ? '</div>' : '' ;
  301.                         echo    ($layout=="one") ? "" : '</div>';
  302.                     }
  303.  
  304.  
  305.                     #
  306.                     #   Call Product Box
  307.                     #
  308.                     if($template->content_type=="product_box"){                
  309.                                
  310.                        
  311.                         $item_width = $template->item_width; //item width
  312.                         $box_border = isset($template->box_border) ? "border" : "" ; //border of the container box
  313.                         $layout     = $template->layout;
  314.                         $template->categories  = isset($template->categories) ? $template->categories : "";
  315.  
  316.                         echo    ($layout=="one") ? "" :'<div class="template_builder box '.$box_border.' '.$layout.' '.$firstBox.'  '.$lastBox.'">';
  317.                         echo    ($box_border) ? '<div class="padding-div">' : '' ;
  318.                    
  319.                                 //page
  320.                                 if($template->pagination){
  321.                                     if (get_query_var('paged') ) {$paged = get_query_var('paged');} elseif ( get_query_var('page') ) {$paged = get_query_var('page');} else {$paged = 1;}
  322.                                 }else{
  323.                                     $paged=0;
  324.                                 }
  325.    
  326.                                 //general query
  327.                                 $args=array(
  328.                                     'post_status'    => 'publish',
  329.                                     'post_type'      => 'products',
  330.                                     'orderby'        => $template->list_orderby,
  331.                                     'order'          => $template->list_order,
  332.                                     'posts_per_page' => $template->item_per_page,
  333.                                     'paged'          => $paged,
  334.                          
  335.                                     'tax_query' => array(
  336.                                         array(
  337.                                             'taxonomy' =>   'product_categories',
  338.                                             'field'    =>   'id',
  339.                                             'terms'    =>   (@$template->categories) ? wpml_lang_object_ids($template->categories,"product_categories") : '',
  340.                                             'operator' =>   ($template->categories)  ? "IN" : "OR"
  341.                                         )
  342.                                     ),                                                                     
  343.                                 );
  344.                                  
  345.                                
  346.                                 get_template_part( 'product_loop', 'product_categories' );
  347.                        
  348.                         echo ($box_border) ? '</div>' : '' ;
  349.                         echo    ($layout=="one") ? "" : '</div>';
  350.                     }      
  351.  
  352.  
  353.                     #
  354.                     #   Call Product Box
  355.                     #
  356.                     if($template->content_type=="blog_box"){               
  357.                                
  358.                        
  359.                         $item_width = isset($template->item_width) ? $template->item_width : "" ; //item width
  360.                         $box_border = isset($template->box_border) ? "border" : "" ; //border of the container box
  361.                         $layout     = $template->layout;
  362.                        
  363.                         echo    ($layout=="one") ? "" :'<div class="template_builder box '.$box_border.' '.$layout.' '.$firstBox.'  '.$lastBox.'">';
  364.                         echo ($box_border) ? '<div class="padding-div">' : '' ;
  365.                    
  366.                                 //page
  367.                                 if($template->pagination){
  368.                                     if (get_query_var('paged') ) {$paged = get_query_var('paged');} elseif ( get_query_var('page') ) {$paged = get_query_var('page');} else {$paged = 1;}
  369.                                 }else{
  370.                                     $paged=0;
  371.                                 }
  372.  
  373.                                 //blog cats
  374.                                 if($template->categories){
  375.                                     $blog_cats=implode(($template->categories),",");
  376.                                 }else{
  377.                                     $blog_cats="";
  378.                                 }
  379.            
  380.                                 //general query
  381.                                 $args=array(
  382.                                     'post_status'    => 'publish',
  383.                                     'post_type'      => 'post',
  384.                                     'orderby'        => $template->list_orderby,
  385.                                     'order'          => $template->list_order,
  386.                                     'posts_per_page' => $template->item_per_page,
  387.                                     'paged'          => $paged,
  388.                                     'cat'            => $blog_cats,
  389.                                 );
  390.                                  
  391.                                
  392.                                 get_template_part( 'loop', 'archive' );
  393.                        
  394.                         echo ($box_border) ? '</div>' : '' ;
  395.                         echo    ($layout=="one") ? "" : '</div>';
  396.                     }      
  397.  
  398.  
  399.                     #
  400.                     #   Call Google Map
  401.                     #
  402.                     if($template->content_type=="google_map"){           
  403.  
  404.                         $box_border = isset($template->box_border) ? "border" : "" ; //border of the container box
  405.                         $layout     = $template->layout;
  406.                        
  407.                         echo '<div class="template_builder box '.$box_border.' '.$layout.' '.$firstBox.'  '.$lastBox.'">';
  408.                         echo ($box_border) ? '<div class="padding-div">' : '' ;
  409.                      
  410.                             //try to find view larger map part
  411.                             $mapiframeCode        = explode('<br /><small>', stripslashes($template->map_url));                            
  412.                             $mapiframeCode        = is_array($mapiframeCode) ? $mapiframeCode[0] : $mapiframeCode ; //cleaned larger map part
  413.                            
  414.                             //find width value
  415.                             $mapiframeCode_Width  = explode('width="', $mapiframeCode);
  416.                             $mapiframeCode_Width  = explode('"', $mapiframeCode_Width[1]);
  417.                             $mapiframeCode_Width  = $mapiframeCode_Width[0];
  418.                            
  419.                             //find height value
  420.                             $mapiframeCode_Height = explode('height="', $mapiframeCode);
  421.                             $mapiframeCode_Height = explode('"', $mapiframeCode_Height[1]);
  422.                             $mapiframeCode_Height = $mapiframeCode_Height[0];
  423.                            
  424.                             //new map width
  425.                             $newMapWidth          = $this_column_width_pixel -20;
  426.                            
  427.                             //final code
  428.                             $mapiframeCode        = str_replace('width="'.$mapiframeCode_Width.'"','width="'.$newMapWidth.'"', $mapiframeCode);
  429.                             $mapiframeCode        = str_replace('height="'.$mapiframeCode_Height.'"','height="'.$template->height.'"', $mapiframeCode);
  430.                              
  431.                             echo $mapiframeCode;
  432.                        
  433.                         echo ($box_border) ? '</div>' : '' ;
  434.                         echo    '</div>';
  435.                     }      
  436.                      
  437.  
  438.                     #
  439.                     #   Call Contact Form
  440.                     #
  441.                     if($template->content_type=="contact_form"){             
  442.  
  443.                         $box_border = isset($template->box_border) ? "border" : "" ; //border of the container box
  444.                         $layout         = $template->layout;
  445.                        
  446.                         echo '<div class="template_builder box '.$box_border.' '.$layout.' '.$firstBox.'  '.$lastBox.'">';
  447.                         echo ($box_border) ? '<div class="padding-div">' : '' ;
  448.                      
  449.                             echo ($template->title) ? '<h3>'.wpml_t( THEMESLUG , 'Text for Contact Form '.$selectedTemplate->templateID, stripslashes($template->title)).'</h3>' :"";
  450.                             echo ($template->description) ? '<div class="space margin-t10"><p class="decs_text"><i>'.wpml_t( THEMESLUG , 'Description for Contact Form '.$selectedTemplate->templateID, stripslashes($template->description)).'</i></div>' :"";
  451.                    
  452.                             //Default Contact Form
  453.                             if($template->email && !$template->shortcode){         
  454.                                 echo    do_shortcode('[contact_form email="'.$template->email.'"]');
  455.                             }
  456.                        
  457.                             //3rd Party Contact Form Plugins
  458.                             if($template->shortcode){
  459.                                 echo    do_shortcode(stripslashes($template->shortcode));
  460.                             }
  461.                        
  462.                         echo ($box_border) ? '</div>' : '' ;
  463.                         echo    '</div>';
  464.                     }      
  465.  
  466.                     #
  467.                     #   Call Contact Info Box
  468.                     #
  469.                     if($template->content_type=="contact_info_box"){             
  470.            
  471.                         $box_border = isset($template->box_border) ? "border" : "" ; //border of the container box
  472.                         $layout     = $template->layout;
  473.                        
  474.                         echo '<div class="template_builder box '.$box_border.' '.$layout.' '.$firstBox.'  '.$lastBox.'">';
  475.                         echo ($box_border) ? '<div class="padding-div">' : '' ;
  476.                      
  477.                             echo ($template->contact_title) ? '<h3>'.wpml_t( THEMESLUG , 'Title for Contact Info '.$selectedTemplate->templateID, stripslashes($template->contact_title) ).'</h3>' :"";
  478.                             echo ($template->contact_text) ? '<div class="space margin-t10"></div><p>'.wpml_t( THEMESLUG , 'Text for Contact Info '.$selectedTemplate->templateID, stripslashes($template->contact_text) ).'</p>' :"";
  479.                             echo '<ul class="contact_list">';
  480.                             echo ($template->address) ? '<li class="home">'.wpml_t( THEMESLUG , 'Address for Contact Info '.$selectedTemplate->templateID, stripslashes($template->address) ).'</li>' :"";
  481.                             echo ($template->phone) ? '<li class="phone">'.wpml_t( THEMESLUG , 'Phone for Contact Info '.$selectedTemplate->templateID, $template->phone ).'</li>' :"";
  482.                             echo ($template->email) ? '<li class="mail"><a href="mailto:'.wpml_t( THEMESLUG , 'Email for Contact Info '.$selectedTemplate->templateID, $template->email ).'">'.wpml_t( THEMESLUG , 'Email for Contact Info '.$selectedTemplate->templateID, $template->email ).'</a></li>' :"";
  483.                             echo ($template->support_email) ? '<li class="help"><a href="mailto:'.wpml_t( THEMESLUG , 'Support Email for Contact Info '.$selectedTemplate->templateID, $template->support_email ).'">'.wpml_t( THEMESLUG , 'Support Email for Contact Info '.$selectedTemplate->templateID, $template->support_email ).'</a></li>' :"";
  484.                             echo ($template->fax) ? '<li class="fax">'.wpml_t( THEMESLUG , 'Fax for Contact Info '.$selectedTemplate->templateID, $template->fax ).'</li>' :"";
  485.                             echo '</ul>';
  486.                            
  487.                         echo ($box_border) ? '</div>' : '' ;
  488.                         echo    '</div>';
  489.                     }    
  490.                    
  491.                     if ($reset && $emptyContent!="true" && $boxNumber != count($selectedTemplate->contents)):
  492.                         echo '<div class="clear"></div><div class="space margin-b30"></div>';                      
  493.                     endif;
  494.                     $emptyContent = false;
  495.                    
  496.         $boxNumber++;
  497.     }
  498.     }
  499.  
  500.     #
  501.     #   Call the holder's 2nd part
  502.     #
  503.     sub_page_layout("subfooter",$sidebar);
  504.     ?>
Advertisement
Add Comment
Please, Sign In to add comment