~george-edison55/jsstudio/addons_site

« back to all changes in this revision

Viewing changes to index.php

  • Committer: Nathan Osman
  • Date: 2011-08-22 04:33:05 UTC
  • Revision ID: admin@quickmediasolutions.com-20110822043305-kk083pea9bjjq5ad
Added ability to download addons.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
{
26
26
    private $controller = 'addons'; // the default controller
27
27
    private $action     = 'index';  // and the default action
 
28
    private $arguments  = array();
28
29
    
29
30
    private function FatalError($details)
30
31
    {
60
61
        if(!preg_match('/^\w+$/', $this->controller) ||
61
62
           !preg_match('/^\w+$/', $this->action))
62
63
            $this->FatalError('The request URL is invalid.');
 
64
        
 
65
        // Now package the rest of the URL into $arguments
 
66
        $this->arguments = $url_parts;
 
67
        array_splice($this->arguments, 0, 2);
63
68
    }
64
69
    
65
70
    public function RunController()
79
84
            $this->FatalError("The class '$class_name' does not exist within the file '$controller_filename'.");
80
85
        
81
86
        // Create an instance of the class
82
 
        $controller_instance = new $class_name();
 
87
        $controller_instance = new $class_name($this->controller);
83
88
        
84
89
        // Make sure the class derives from BaseController
85
90
        if(!$controller_instance instanceof BaseController)
91
96
            $this->FatalError("The class '$class_name' does not contain a method for the action '$method_name'.");
92
97
        
93
98
        // Okay, now invoke the method
94
 
        $controller_instance->$method_name();
 
99
        call_user_func_array(array($controller_instance, $method_name),
 
100
                             $this->arguments);
95
101
        
96
102
        // Return the view variables that were created by the controller
97
103
        return $controller_instance->GetViewVariables();