Advertisement
b4lduin

design manager php

Jun 7th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.99 KB | None | 0 0
  1. <?php
  2. //check if the template has the needed Data
  3. if($class_support->checkTemplateCompatible($edit_template))
  4. {
  5.     $template_id    = $class_support->getTemplateId($edit_template);
  6.  
  7.     //...
  8.  
  9.     //check if temp layouts exist and ask to load
  10.     if($class_support->checkForTempLayouts($template_id) && !isset($_GET['tl']))
  11.     {
  12.         $module_select_content = '<form method="get" action="' . $action . '">
  13.                                         <p class="temp_layout_load_ask">
  14.                                             ' . $class_support->getTranslation('load_temp_layout_ask', $benutzer_sprache) . '
  15.                                         </p>
  16.                                         <input type="hidden" name="t" id="t" value="' . $edit_template . '"/>
  17.                                         <input type="hidden" name="tl" id="tl" value="0" />
  18.                                         <p class="temp_layout_load_ask">
  19.                                             <input type="submit" value="' . $class_support->getTranslation('yes', $benutzer_sprache) . '" onclick="document.getElementById(\'tl\').value=1" />
  20.                                             <input type="submit" value="' . $class_support->getTranslation('no', $benutzer_sprache) . '" />
  21.                                         </p>
  22.                                     </form>';
  23.     }
  24.     else
  25.     {
  26.         if(isset($_GET['tl']))
  27.         {
  28.             if($_GET['tl'] == 1)
  29.             {
  30.                 $load_temp = true;
  31.             }
  32.             else
  33.             {
  34.                 $load_temp = false;
  35.             }
  36.         }
  37.         else
  38.         {
  39.             $load_temp = false;
  40.         }
  41.  
  42.         //loading all needed data to create the module select
  43.         $template_layouts   = new Template_Layouts($template_id,$benutzer_sprache, $load_temp);
  44.  
  45.         $layouts            = $template_layouts->getLayouts();
  46.  
  47.         $tabs               = '';
  48.         $tab_content        = '';
  49.  
  50.         //echo '<pre>';var_export($layouts);echo '</pre>';
  51.  
  52.         //create for each layout a module select
  53.         foreach($layouts as $layout)
  54.         {
  55.             $template_layout    = $layout['display_layout'];
  56.             $layout_id          = $template_layout->getLayoutId();
  57.             $display_reset_btn  = '';
  58.             $preview_opt        = '';
  59.  
  60.             //setting up the ids to start at the last save
  61.             if($load_temp == true)
  62.             {
  63.                 $tmp    = $template_layout->getReferenceId();
  64.                
  65.                 if(!is_null($tmp))
  66.                 {
  67.                     $temp_id    = $layout_id;
  68.                     $layout_id  = $tmp;
  69.                 }
  70.                 else
  71.                 {
  72.                     $temp_id = '';
  73.                 }
  74.             }
  75.             else
  76.             {
  77.                 $temp_id    = '';
  78.             }
  79.            
  80.             //don't display the reset btn for the base display and empty displays
  81.             if((int)$layout_id != 0  && $template_layout->getDefaultLayout() == 0)
  82.             {
  83.                 $display_reset_btn = '<img src="../shop_admin/images/close_16.png" onclick="resetDisplay(' . $layout['display_id'] . ');" title="' . $class_support->getTranslation('reset_display', $benutzer_sprache) . '" class="delete_img"/>';
  84.             }
  85.  
  86.             //2013.09.12 MD: ausnahme für die kategorien bis die vorschau umgebaut wurde.
  87.             if($layout['display_id'] != 3)
  88.             {
  89.                 $preview_opt = '<input type="button" value="' . $class_support->getTranslation('preview', $benutzer_sprache) . '" onclick="showPreview(\'' . $layout_id . '\');" />
  90.                                 <span style="float:right;text-decoration:none;">
  91.                                     <input title="' . $class_support->getTranslation('hold_preview_tipp', $benutzer_sprache) . '" type="checkbox" id="hold_preview_' . $layout['display_id'] . '" class="hold_preview" name="hold_preview" value="' . $layout_id . '"/>
  92.                                     <label title="' . $class_support->getTranslation('hold_preview_tipp', $benutzer_sprache) . '" for="hold_preview_' . $layout['display_id'] . '">
  93.                                         ' . $class_support->getTranslation('hold_preview', $benutzer_sprache) . '
  94.                                     </label>
  95.                                 </span>';
  96.             }
  97.  
  98.             $tabs   .= '<li>
  99.                             ' . $display_reset_btn . '
  100.                             <a href="#' . $layout_id . '">' . $layout['display_name'] . '</a>
  101.                         </li>';
  102.            
  103.             //setting the data for each accordion section
  104.             $accordion_data = array
  105.             (
  106.                 'module'        => $template_layout->getLayoutModules()->getFreeModules(),
  107.                 'place_box'     => $template_layout->getLayoutPlaceholders()->getFreePlaceholdersBox(),
  108.                 'place'         => $template_layout->getLayoutPlaceholders()->getFreePlaceholders(),
  109.                 'pic_slide'     => $template_layout->getPictureSliders()->getFreeSliders(),
  110.                 'prod_slide'    => $template_layout->getProductSliders()->getFreeSliders()
  111.             );
  112.            
  113.             //filling the accordion with data
  114.             foreach($accordion_data as $ac_section => $section_data)
  115.             {
  116.                 //section header with div for trash
  117.                 $section_string = '<div class="' . $ac_section . '_container">';
  118.  
  119.                 //inserting the free objects into the container
  120.                 foreach($section_data as $move_object)
  121.                 {
  122.                     $title_link_a = '';
  123.                     $title_link_b = '';
  124.  
  125.                     //MD: 2013-09-23 added links to the settings of each element
  126.                     if($ac_section == 'module') //setting the variables if it is a module
  127.                     {
  128.                         $internal_name = $move_object->getModuleInternalName();
  129.                        
  130.                         if(in_array($internal_name, $module_manager_modules))
  131.                         {
  132.                             //...
  133.                         }
  134.  
  135.                         $sizes      = $move_object->getModuleSizes();
  136.                         $temp_title = $move_object->getModuleName();
  137.                         $object_id  = $move_object->getModuleId();
  138.                     }
  139.                     else if($ac_section == 'place' || $ac_section == 'place_box') //setting the variables if it is a placeholder - box
  140.                     {
  141.                         $sizes      = $move_object->getPlaceholderSizes();
  142.                         $temp_title = $move_object->getPlaceholderTitle();
  143.                         $object_id  = $move_object->getPlaceholderId();
  144.                        
  145.                         //...
  146.  
  147.                         if($ac_section == 'place')
  148.                         {
  149.                             $object_id = 'p_' . $object_id;
  150.                         }
  151.                         else
  152.                         {
  153.                             $object_id = 'pb_' . $object_id;
  154.                         }
  155.                     }
  156.                     else if($ac_section == 'pic_slide' || $ac_section == 'prod_slide')
  157.                     {
  158.                         $temp_title = $move_object->getSliderTitle();
  159.                        
  160.                         if($ac_section == 'pic_slide')
  161.                         {
  162.                             $sizes      = $move_object->getSliderSizes();
  163.                             $object_id  = $move_object->getSliderId();
  164.  
  165.                             //...
  166.  
  167.                             $object_id  = 'ps_' . $object_id;
  168.                         }
  169.                         else
  170.                         {
  171.                             $sizes      = $move_object->getSliderSizes();
  172.                             $object_id  = $move_object->getSliderId();
  173.  
  174.                             //...
  175.  
  176.                             $object_id  = 'pr_' . $object_id;
  177.                         }
  178.                     }
  179.  
  180.                     //2013-07-16 MD: added to enable the reset of an element
  181.                     $reset_button   = '<img class="drag_reset_img" onclick="resetElement(\'' . $layout_id . '\', \'' . $object_id . '\', \'' . $ac_section . '_container\')" title="' . $class_support->getTranslation('reset_element', $benutzer_sprache) . '" src="../shop_admin/images/close_16.png" />';
  182.                     //creating the div which shows the user the available sizes
  183.                     $size_display   = '<div class="module_size_container">';
  184.  
  185.                     foreach($sizes as $size)
  186.                     {
  187.                         $size_display .= '<span title="' . $class_support->getTranslation($ac_section . '_size_noti', $benutzer_sprache) . '" class="size_noti_' . $size . '"></span>';
  188.                     }
  189.  
  190.                     $size_display   .= '</div>';
  191.                    
  192.                     //2013-10-15 MD: #6745 changed to css to use always the available space
  193.                     $module_title   = '<span class="text_center" title="' . $temp_title . '">' . $title_link_a . $temp_title . $title_link_b . '</span>';
  194.                     $handle         = '<span class="select_handle" title="' . $class_support->getTranslation('drag_element', $benutzer_sprache) . '"></span>';
  195.                    
  196.                     $section_string .= '<div data-sizes="' . implode('|', $sizes) . '" data-id="' . $object_id . '" class="' . $ac_section . '_drag">' . $reset_button . $size_display . $handle . $module_title . '</div>';
  197.                 }
  198.  
  199.                 $section_string .= '</div>';
  200.  
  201.                 if($ac_section == 'module')
  202.                 {
  203.                     $available_modules          = $section_string;
  204.                 }
  205.                 else if($ac_section == 'place_box')
  206.                 {
  207.                     $available_placeholders_box = $section_string;
  208.                 }
  209.                 else if($ac_section == 'place')
  210.                 {
  211.                     $available_placeholders     = $section_string;
  212.                 }
  213.                 else if($ac_section == 'pic_slide')
  214.                 {
  215.                     $available_pic_sliders = $section_string;
  216.                 }
  217.                 else if($ac_section == 'prod_slide')
  218.                 {
  219.                     $available_prod_sliders = $section_string;
  220.                 }
  221.             }
  222.  
  223.             //inserting the containers into the accordion
  224.             $accordion      = '<div class="module_accordion">
  225.                                     <h3>' . $class_support->getTranslation('modules', $benutzer_sprache) . '</h3>
  226.                                         ' . $available_modules . '
  227.                                     <h3>' . $class_support->getTranslation('placeholders_box', $benutzer_sprache) . '</h3>
  228.                                         ' . $available_placeholders_box . '
  229.                                     <h3>' . $class_support->getTranslation('placeholders', $benutzer_sprache) . '</h3>
  230.                                         ' . $available_placeholders . '
  231.                                     <h3>' . $class_support->getTranslation('picture_sliders', $benutzer_sprache) . '</h3>
  232.                                         ' . $available_pic_sliders . '
  233.                                     <h3>' . $class_support->getTranslation('product_sliders', $benutzer_sprache) . '</h3>
  234.                                         ' . $available_prod_sliders . '
  235.                                 </div>';
  236.  
  237.             $template_structure = '<table cellpadding="0" cellspacing="0">
  238.                                         <tr>
  239.                                             <td class="accordion">
  240.                                                 ' . $accordion . '
  241.                                             </td>
  242.                                             <td class="template_structure" data-layout-id="' . $layout_id . '">
  243.                                                 <input type="hidden" class="temp_layout_id" data-id="' . $layout_id . '" value="' . $temp_id . '" />
  244.                                                 <div class="button_row">
  245.                                                     ' . $class_support->getTranslation('choosen_display', $benutzer_sprache) . '
  246.                                                     <span>' . $layout['display_name'] . '</span>
  247.                                                     <input type="button" value="' . $class_support->getTranslation('save', $benutzer_sprache) . '" onclick="templateSave();" />
  248.                                                     ' . $preview_opt . '
  249.                                                 </div>
  250.                                                 ' . $template_layout->getTemplateStructure() . '
  251.                                             </td>
  252.                                             <td valign="top" width="50" align="center">
  253.                                                 <a href="' . $help_link . '" target="_blank" title="zum Handbuch">
  254.                                                   <img src="../shop_admin/images/help_blue.png" style="margin-right: 7px; padding-top:2px;border:0px;">Hilfe</a>
  255.                                               </td>
  256.                                         </tr>
  257.                                     </table>';
  258.  
  259.             $tab_content .= '<div id="' . $layout_id . '">' . $template_structure . '</div>';
  260.         }
  261.  
  262.         if($class_support->templateIsResponsive($edit_template))
  263.         {
  264.             $column_number = 6;
  265.         }
  266.         else
  267.         {
  268.             $column_number = 5;
  269.         }
  270.  
  271.         $responsive_code = '<input type="hidden" id="template_columns" value="' . $column_number . '" />
  272.                             <style type="text/css">
  273.                                 .module_size_container span:first-child:nth-last-child(' . $column_number . '),
  274.                                 .module_size_container span:first-child:nth-last-child(' . $column_number . ') ~ span
  275.                                 {
  276.                                     display: none;
  277.                                 }
  278.                             </style>';
  279.  
  280.         //inserting the generated code
  281.         $module_select_content = '<div id="layout_tabs">
  282.                                         <ul>
  283.                                             ' . $tabs . '
  284.                                         </ul>
  285.                                         ' . $tab_content . '
  286.                                     </div>
  287.                                     <input type="hidden" id="template_id" name="template_id" value="' . $template_layouts->getTemplateId() . '" />
  288.                                     <input type="hidden" id="template_name" name="template_name" value="' . $edit_template . '" />
  289.                                     ' . $responsive_code . '
  290.                                 <input type="hidden" id="language" name="language" value="' . $benutzer_sprache . '" />
  291.                                 <div style="display:none" id="position_error" title="' . $class_support->getTranslation('position_error_title', $benutzer_sprache) . '" ></div>
  292.                                 <div style="display:none" id="save_notice"></div>';
  293.     }
  294. }
  295. else
  296. {
  297.     $module_select_content = '<p class="error">' . $class_support->getTranslation('not_compatible', $benutzer_sprache) . '</p>';
  298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement