Example #1
0
function table_name_to_class_name($tablename)
{
    return joined_lower_to_camel_case(singularize($tablename));
}
Example #2
0
 /**
  *	@short Renders a view from a controller other than self.
  *	@details This method renders a view from a controller other than self,
  *	for example when embedding a view into another view.
  *
  *	The <tt>params</tt> array has the same semantics of the <tt>render</tt> method,
  *	with the following additions:
  *
  *	<tt>controller</tt>: the name of the controller responsible for the view (defaults to self).
  *	@param params Parameters defining how the rendering should be realized.
  */
 public function render_component($params)
 {
     // Merge request and user parameters
     $_GET = array_merge($_GET, $params);
     // If a controller is not set, use current controller
     if (!isset($params['controller'])) {
         $controller_name = $this->name;
     } else {
         // Use the value stored in params as controller name
         $controller_name = basename($params['controller']);
         // Include the controller class file
         require_once dirname(__FILE__) . '/../controllers/' . $controller_name . '_controller.php';
         // Load localization table
         Localization::add_strings_table($controller_name);
     }
     // Create class name
     $classname = joined_lower_to_camel_case($controller_name) . 'Controller';
     // Instantiate controller
     $controller = new $classname();
     // Unset controller key from params (why?)
     unset($params['controller']);
     // Set requested action
     if (isset($params['action'])) {
         $action = basename($params['action']);
         $controller->action = $action;
     }
     // Invoke action method
     $controller->{$action}();
     // Request rendering with no layout
     $params['layout'] = FALSE;
     // Note that this could already have been called
     $controller->render($params);
 }
Example #3
0
<?php

require_once dirname(__FILE__) . "/include/common.inc.php";
require_once dirname(__FILE__) . "/helpers/application_helper.php";
require_once dirname(__FILE__) . "/helpers/http.php";
define('APPLICATION_ROOT', '/');
if (isset($_REQUEST['controller']) && !empty($_REQUEST['controller'])) {
    // Get controller name
    $controller = basename($_REQUEST['controller']);
    // Include controller class
    $controller_file = dirname(__FILE__) . "/controllers/{$controller}_controller.php";
    if (!file_exists($controller_file)) {
        HTTP::error(404);
    }
    require $controller_file;
    // Instantiate main controller
    $main_controller = eval("return new " . joined_lower_to_camel_case($_REQUEST['controller']) . "Controller();");
    // Request rendering of the page
    $main_controller->render_page();
} else {
    HTTP::error(500);
}