Exemplo n.º 1
0
function include_partial($url)
{
    $url_exp = explode(":", $url);
    $context = odContext::getInstance();
    if (strtolower($url_exp[0]) == "tpl") {
        $view = new odView($context->get_view("view.0")->get_datas(), $context->get_view("view.0")->get_args());
        $view->set_template_name("templates/" . $url_exp[1] . ".tpl");
        $view->show();
    }
    if (strtolower($url_exp[0]) == "url") {
        $url = explode('/', $url_exp[1]);
        if ($url[0] == "") {
            $url[0] = "/";
        } else {
            $url[1] = $url[0];
            $url[0] = "/";
        }
        $request_initial = $context->get_request("request.initial");
        $referer = $request_initial->get_referer();
        $request_count = $context->get_request_count();
        $request_name = "partial.request." . $request_count;
        // lancement de forward du controller
        $controller = $context->get_current_controller();
        $controller->forward($url, $request_name, $referer);
    }
}
Exemplo n.º 2
0
function image_tag($source, $options = array(), $html = false)
{
    $url_path = odContext::getInstance()->get_request("request.initial")->get_referer();
    $url_path .= "/images/" . $source;
    if (!is_array($options)) {
        $options_tab = __transform_string_into_tab($options);
    } else {
        $options_tab = $options;
    }
    $options_tab = array_merge(array("src" => $url_path), $options_tab);
    if (array_key_exists("size", $options_tab)) {
        $size_exploded = explode("x", $options_tab["size"]);
        unset($options_tab["size"]);
        if (isset($size_exploded[0])) {
            $options_tab = array_merge($options_tab, array("width" => $size_exploded[0]));
        }
        if (isset($size_exploded[1])) {
            $options_tab = array_merge($options_tab, array("height" => $size_exploded[1]));
        }
    }
    if ($html) {
        return html_simple_tag("img", $options_tab);
    } else {
        simple_tag("img", $options_tab);
    }
}
Exemplo n.º 3
0
 public static function initialize($application_path)
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new odContext($application_path);
         return self::$_instance;
     }
 }
Exemplo n.º 4
0
 public function activate($args)
 {
     $modelresult = $this->getModel()->load($this->module, $this->method, $args);
     $viewclass = $this->module . $this->method . "View";
     $viewclass = trim($viewclass, "/");
     if (class_exists($viewclass) && !isset($_POST['form'])) {
         $this->view = new $viewclass($modelresult, $args);
         $context = odContext::getInstance();
         $context->add_view("view." . $context->get_views_count(), $this->view);
         $this->view->show();
     }
 }
Exemplo n.º 5
0
 public function __construct($name, $rule)
 {
     $this->rule = $rule;
     $this->name = $name;
     $this->_rules = odContext::getInstance()->get_routing_rules();
     $this->_modules = odContext::getInstance()->get_modules();
     foreach ($this->_rules as $r_key => $r_val) {
         if (in_array($r_val["module"], array_keys($this->_modules))) {
             $this->_rules[$r_key]["module"] = $this->_modules[$this->_rules[$r_key]["module"]];
         }
     }
 }
Exemplo n.º 6
0
 public function load($module, $method, $args)
 {
     $app_name = odContext::getInstance()->get_application_name();
     $orchid_path = odContext::getInstance()->get_orchid_path();
     if (isset($_POST["form"])) {
         if (method_exists($this, "perform")) {
             ${$this->get_model_name()} = $this->perform($args);
         } else {
             throw new odException("You have to define the method perform in " . $method . " model class");
         }
     } else {
         ${$this->get_model_name()} = $this->action($args);
     }
     return ${$this->get_model_name()};
 }
Exemplo n.º 7
0
 public function find_controller($url)
 {
     // get the application config
     $appcontext = odContext::getInstance()->get_app_config();
     $controller = null;
     $controller_found = false;
     foreach ($appcontext["controllers"] as $app_key => $app_val) {
         if ($url[0] == $app_key) {
             // we have found a known controller
             $controller = $app_val;
             $controller_found = true;
             break;
         }
     }
     if (!$controller_found) {
         // we don't found any controller so we take the default controller
         $controller = $appcontext["controllers"]["default"];
     }
     $this->controller = $controller;
     return $controller_found;
 }
Exemplo n.º 8
0
 public function trigger_route($url, $request_name, $referer)
 {
     // construction de la requête
     $request = new odRequest();
     $request->set_referer($referer);
     //recherche du controller
     $controller_found = $request->find_controller($url);
     // mémorisation de la requête dans le contexte
     odContext::getInstance()->add_request($request_name, $request);
     // suppression du controller dans l'uri
     if ($controller_found) {
         array_shift($url);
     }
     if (count($url) == 1) {
         $url[1] = $url[0];
         $url[0] = "/";
     }
     $rule = $request->decode_url($url);
     // rule is ok, so we call the good action
     $action = new odAction($rule[0]);
     $action->activate($rule[1]);
 }
Exemplo n.º 9
0
 public function __construct($filename)
 {
     if (isset($_SESSION["lang"])) {
         $lang = $_SESSION["lang"];
     } else {
         if (isset($_GET["lang"])) {
             $lang = $_GET["lang"];
         } else {
             if (isset($_POST["lang"])) {
                 $lang = $_POST["lang"];
             } else {
                 $lang = "fr_FR";
             }
         }
     }
     $context = odContext::getInstance();
     $app_path = $context->get_application_path();
     $nameoffile = $app_path . "/ressources/" . $filename . "_" . $lang . ".prop";
     if (file_exists($nameoffile)) {
         $fileContent = file($nameoffile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
         foreach ($fileContent as $line) {
             if (substr($line, 0, 2) == "##") {
                 continue;
             }
             $lineexp = explode("=", $line);
             if (count($lineexp) < 2) {
                 throw new Exception("odLang constructor : property '" . $line . "' doesnt complete");
             }
             $messtab = array_slice($lineexp, 1);
             $message = implode("=", $messtab);
             $this->_langFileContent[$lineexp[0]] = $message;
         }
         unset($fileContent);
     } else {
         throw new Exception("odLang constructor : file '" . $nameoffile . "' doesnt exists");
     }
 }
Exemplo n.º 10
0
 public function staticRedirect($route)
 {
     $request_referer = odContext::getInstance()->get_request("request.initial")->get_referer();
     header("Location:" . $request_referer . "/" . $route);
 }
Exemplo n.º 11
0
function staticUrl($uri)
{
    $request_referer = odContext::getInstance()->get_request("request.initial")->get_referer();
    return $request_referer . "/" . $uri;
}
Exemplo n.º 12
0
 public function get_cookie_hash()
 {
     return odContext::getInstance()->get_cookie_hash();
 }
Exemplo n.º 13
0
 public function getInsertId()
 {
     return mysqli_insert_id(odContext::getInstance()->get_dblink());
 }