Esempio n. 1
0
 /**
  * Include a file if needed - we allow a relative path from minisite_templates/modules/ or an absolute path.
  */
 private final function _setup_mvc($type, $params = NULL)
 {
     if (!in_array($type, array('controller', 'model', 'view'))) {
         trigger_warning('The type passed (' . $type . ') to _setup_mvc must be "controller", "model", or "view"', 1);
         return NULL;
     }
     if (!empty($params['file']) || !empty($this->{$type})) {
         if (empty($params['file']) || !empty($this->{$type})) {
             $params['file'] = $this->{$type};
         }
         if (reason_file_exists('minisite_templates/modules/' . $params['file'])) {
             reason_include_once('minisite_templates/modules/' . $params['file']);
             $full_path = reason_resolve_path('minisite_templates/modules/' . $params['file']);
         } elseif (reason_file_exists($params['file'])) {
             reason_include_once($params['file']);
             $full_path = reason_resolve_path($params['file']);
         } elseif (file_exists($params['file'])) {
             include_once $params['file'];
             $full_path = realpath($params['file']);
         } else {
             trigger_error('The mvc module was unable to load the ' . $type . ' (' . $params['file'] . ')', FATAL);
         }
         if (isset($GLOBALS['_reason_mvc_' . $type . '_class_names'][reason_basename($full_path)])) {
             $class_name = $GLOBALS['_reason_mvc_' . $type . '_class_names'][reason_basename($full_path)];
         } else {
             trigger_error('The mvc module was unable to determine the class name for the ' . $type . ' (' . $params['file'] . ') - check that the file properly registers itself.', FATAL);
         }
         unset($params['file']);
     } else {
         if ($type == 'controller') {
             $class_name = 'ReasonMVCController';
         }
         // setup the default controller
     }
     // instantiate and return it.
     if (isset($class_name)) {
         $obj = new $class_name();
         $this->configure_mvc($type, $obj, $params);
         return $obj;
     }
 }
Esempio n. 2
0
/** @access private */
function _parse_async_upload_authenticator($auth)
{
    if (!is_array($auth) || empty($auth)) {
        trigger_fatal_error("upload authenticator must be specified as an " . "array as per the reason_create_async_upload_session API docs; " . "instead got " . var_export($auth, true), 2);
    }
    $callback = array_shift($auth);
    if ($inc_type = _detect_filename($callback)) {
        $filename = $callback;
        $callback = array_shift($auth);
    } else {
        $filename = null;
    }
    if ($filename) {
        if ($inc_type == "absolute" && !file_exists($filename)) {
            trigger_fatal_error("upload authenticator file " . var_export($filename, true) . " does not exist", 2);
        } else {
            if ($inc_type == "relative") {
                if (!reason_file_exists($filename)) {
                    trigger_fatal_error("upload authenticator file " . var_export($filename, true) . " does not exist in either " . "the local or the core Reason lib directory", 2);
                }
                $filename = reason_resolve_path($filename);
            }
        }
    }
    return array("file" => $filename, "callback" => $callback, "arguments" => $auth);
}