source: trunk/controller.php @ 2341

Revision 2341, 2.3 KB checked in by rodsouza, 14 years ago (diff)

Ticket #911 - Utilizando o formato proveniente do eGroupWare para acesso ao módulo ou seja 'menuaction'.

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