source: trunk/expressoAdmin1_2/controller.php @ 317

Revision 317, 1.7 KB checked in by niltonneto, 16 years ago (diff)

Versionamento feito pelo desenvolvedor (jakjr).

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        //      Explode action from cExecuteForm function
3        $cExecuteFormReturn = false;
4        if($_POST['_action']) {                 
5                if($_FILES) {
6                        $count_files = $_POST['countFiles'];
7                        $array_files = array();                 
8                        for($idx = 1; $idx <= $count_files; $idx++) {           
9                                if($_FILES['file_'.$idx] && !$_FILES['file_'.$idx]['error'])
10                                        $array_files[] = $_FILES['file_'.$idx];                                         
11                        }
12                        $_POST['FILES'] = $array_files;
13                }                               
14                list($app,$class,$method) = explode('.',@$_POST['_action']);
15                $cExecuteFormReturn = true;
16        }
17        //      Explode action from cExecute function
18        else if($_GET['action'])
19                list($app,$class,$method) = explode('.',@$_GET['action']);
20        // NO ACTION
21        else
22                return $_SESSION['response'] = 'false';
23               
24        // Load dinamically class file.
25        if($app == '$this')
26                $filename = 'inc/class.'.$class.'.inc.php';
27        else if( strpos($app, '$this/') !== false)
28        {
29                $filename = str_replace('$this/','',$app) . '.php';
30                include_once($filename);
31                exit;
32        }
33        else
34                $filename = '../'.$app.'/inc/class.'.$class.'.inc.php';
35               
36        include_once($filename);
37       
38        // Create new Object  (class loaded).   
39        $obj = new $class;
40       
41        // Prepare parameters for execution.   
42        $params = array();
43       
44        // If array $_POST is not null , the submit method is POST.
45        if($_POST) {
46                $params = $_POST;
47        }
48        // If array $_POST is null , and the array $_GET > 1, the submit method is GET.
49        else if(count($_GET) > 1)       {               
50                array_shift($_GET);
51                $params = $_GET;
52        }
53
54        $result = array();
55       
56       
57        // if params is not empty, then class method with parameters.   
58        if($params)
59                $result = $obj -> $method($params);
60        else           
61                $result = $obj -> $method();
62               
63        // Return result serialized.   
64       
65
66        if(!$cExecuteFormReturn)
67                echo serialize($result);
68        else
69                $_SESSION['response'] = $result;
70?>
Note: See TracBrowser for help on using the repository browser.