Advertisement
b4lduin

Admin PHP

Jun 7th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.26 KB | None | 0 0
  1.     /**
  2.      * function to display the selected backend page
  3.      * @author MD
  4.      * @date   2017-12-06
  5.      * @param array           $data
  6.      * @param Multi_Lang|null $class_multi_lang
  7.      * @return bool|string
  8.      */
  9.     public function showSection($data, Multi_Lang $class_multi_lang = null)
  10.     {
  11.         if(!array_key_exists('section', $data) || !array_key_exists($data['section'], $this->section_mapping))
  12.         {
  13.             return false;
  14.         }
  15.  
  16.         if(is_null($class_multi_lang))
  17.         {
  18.             $class_multi_lang = new Multi_Lang('backend', $_SESSION['admin_lang'], true);
  19.         }
  20.  
  21.         $this->class_multi_lang = $class_multi_lang;
  22.  
  23.         $section_info = $this->section_mapping[$data['section']];
  24.  
  25.         if(!empty($section_info['class']))
  26.         {
  27.             $section_object = new $section_info['class']($class_multi_lang, $this->shop_settings);
  28.         }
  29.         else
  30.         {
  31.             $section_object = $this;
  32.         }
  33.  
  34.         if(is_object($section_object))
  35.         {
  36.             $base_function = $section_info['function'];
  37.  
  38.             if(!empty($data['action']) && isset($section_info['actions'][$data['action']]))
  39.             {
  40.                 $base_function = $section_info['actions'][$data['action']];
  41.             }
  42.  
  43.             if(is_callable(array($section_object, $base_function)))
  44.             {
  45.                 if(count($data) == 3) // with the parameters it is the default call so only transmit the id
  46.                 {
  47.                     $response = $section_object->$base_function($data['id']);
  48.                 }
  49.                 else
  50.                 {
  51.                     //first make a copy of the complete data then remove the section and action so only the needed data remains
  52.                     $function_data = $data;
  53.  
  54.                     unset($function_data['section']);
  55.                     unset($function_data['action']);
  56.  
  57.                     $response = $section_object->$base_function($function_data);
  58.                 }
  59.  
  60.  
  61.                 if($response['status'])
  62.                 {
  63.                     $wiki_section   = $this->wikiReplaces($section_info['wiki'][$_SESSION['admin_lang']]);
  64.  
  65.                     $response['js_files']       = $section_info['js_files'];
  66.                     $response['css_files']      = $section_info['css_files'];
  67.                     $response['help_section']   = $section_info['handbook'][$_SESSION['admin_lang']];
  68.                     $response['help_text']      = $this->getHelpText($wiki_section, $_SESSION['admin_lang'], $this->shop_settings['shop_id']);
  69.                 }
  70.  
  71.                 return $response;
  72.             }
  73.             else
  74.             {
  75.                 return 'Error function does not exist or is not callable';
  76.             }
  77.         }
  78.         else
  79.         {
  80.             return 'Error while loading module';
  81.         }
  82.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement