Esempio n. 1
0
 public function index($cmd)
 {
     $path = JPATH_SITE . '/components/com_acctexp/toolbox';
     if (empty($cmd)) {
         $list = array();
         $files = xJUtility::getFileArray($path, 'php', false, true);
         asort($files);
         foreach ($files as $n => $name) {
             $file = $path . '/' . $name;
             include_once $file;
             $class = str_replace('.php', '', $name);
             $tool = new $class();
             if (!method_exists($tool, 'Info')) {
                 continue;
             }
             $info = $tool->Info();
             $info['link'] = AECToolbox::deadsureURL('administrator/index.php?option=com_acctexp&task=index&entity=toolbox&cmd=' . $class);
             $list[] = $info;
         }
         HTML_AcctExp::toolBox('', $list);
     } else {
         $file = $path . '/' . $cmd . '.php';
         include_once $file;
         $tool = new $cmd();
         $info = $tool->Info();
         $return = '';
         if (!method_exists($tool, 'Action')) {
             $return .= '<section class="paper">' . '<p>Tool doesn\'t have an action to carry out!</p>' . '</section>';
         } else {
             $response = '</section><section class="paper"><h4>' . JText::_('Response') . '</h4>' . $tool->Action() . '</section>';
             if (method_exists($tool, 'Settings')) {
                 $tb_settings = $tool->Settings();
                 if (!empty($tb_settings)) {
                     $lists = array();
                     if (isset($tb_settings['lists'])) {
                         $lists = $tb_settings['lists'];
                         unset($tb_settings['lists']);
                     }
                     // Get preset values from POST
                     foreach ($tb_settings as $n => $v) {
                         if (isset($_POST[$n])) {
                             $tb_settings[$n][3] = $_POST[$n];
                         }
                     }
                     $settings = new aecSettings('TOOLBOX', 'E');
                     $settings->fullSettingsArray($tb_settings, array(), $lists);
                     // Call HTML Class
                     $aecHTML = new aecHTML($settings->settings, $settings->lists);
                     foreach ($tb_settings as $n => $v) {
                         $return .= $aecHTML->createSettingsParticle($n);
                     }
                     $return .= '<input type="submit" class="btn btn-primary pull-right"/><br/><br/>';
                 }
             }
             $return .= $response;
         }
         HTML_AcctExp::toolBox($cmd, $return, $info['name']);
     }
 }