function smarty_function_rewriteurl($params, &$smarty)
{
    $controller = "";
    $action = "";
    $langue = "";
    extract($params);
    $param = array();
    foreach ($params as $name => $value) {
        if ($name == "controller" || $name == "action" || $name == "langue") {
            continue;
        }
        $param[$name] = $value;
    }
    echo Core::rewriteURL($controller, $action, $param, $langue);
}
function smarty_function_getPagination($params, &$smarty)
{
    $test = false;
    $info = array();
    $noPage = 0;
    extract($params);
    if (empty($info) || $info["nbPages"] < 2) {
        return;
    }
    if (isset($info["noPage"])) {
        $noPage = $info["noPage"];
    }
    if (isset($_GET["page"])) {
        $test = true;
    }
    $_GET["page"] = $info["currentPage"] - 1;
    echo '<div class="pagination"><div class="previous">';
    echo '<a href="' . Core::rewriteURL(Core::$controller, Core::$action, $_GET) . '" class="button ' . ($info["currentPage"] == 1 ? 'disabled' : '') . '">' . Dictionary::term("global.pagination.previous") . '</a> ';
    echo '</div><div class="pages">';
    if ($noPage) {
        echo $info["currentPage"] . " / " . $info["nbPages"];
    } else {
        for ($i = 1; $i <= $info["nbPages"]; ++$i) {
            if ($i == 1 || $i == $info["currentPage"] || $i == $info["currentPage"] + 1 || $i == $info["currentPage"] - 1 || $i == $info["nbPages"]) {
                $_GET["page"] = $i;
                if ($i > 1) {
                    echo ' - ';
                }
                if ($i == $info["currentPage"]) {
                    echo '<span class="current_page">' . $i . '</span>';
                } else {
                    echo '<a href="' . Core::rewriteURL(Core::$controller, Core::$action, $_GET) . '" class="button">' . $i . '</a>';
                }
            }
            if (($i == $info["currentPage"] + 2 || $i == $info["currentPage"] - 2) && ($i != 1 && $i != $info["nbPages"])) {
                echo " - ... ";
            }
        }
    }
    echo '</div>';
    $_GET["page"] = $info["currentPage"] + 1;
    echo '<div class="next">';
    echo '<a href="' . Core::rewriteURL(Core::$controller, Core::$action, $_GET) . '" class="button ' . ($info["currentPage"] == $info["nbPages"] || !$info["nbPages"] ? 'disabled' : '') . '">' . Dictionary::term("global.pagination.next") . '</a>';
    echo "</div></div>";
    if (!$test) {
        unset($_GET["page"]);
    }
}
Beispiel #3
0
 public function __construct($pFile)
 {
     if (!file_exists($pFile)) {
         return;
     }
     $this->items = SimpleJSON::import($pFile);
     if (!$this->items) {
         trigger_error('[Object Menu] No Items loaded', E_USER_NOTICE);
     }
     foreach ($this->items as &$item) {
         if (!isset($item['parameters'])) {
             $item['parameters'] = array();
         }
         if (!isset($item['controller'])) {
             $item['controller'] = '';
         }
         if (!isset($item['action'])) {
             $item['action'] = '';
         }
         $item['current'] = Core::$controller == $item['controller'] && Core::$action == $item['action'];
         $item['url'] = Core::rewriteURL($item['controller'], $item['action'], $item['parameters']);
     }
 }
Beispiel #4
0
 /**
  * @param array|null $pParams
  * @param Smarty $pSmarty
  * @param bool $pReturn
  * @return string|void
  */
 public function display(array $pParams = null, &$pSmarty = null, $pReturn = false)
 {
     $noForm = false;
     $noMandatory = false;
     $output = $idForm = $classes = "";
     $controller = Core::$controller;
     $action = Core::$action;
     $helper = "core\\tools\\form\\FormHelpers";
     if ($pParams != null) {
         extract($pParams, EXTR_REFS);
     }
     if (!$noForm) {
         $n = array();
         $s = array("controller", "action", "noForm", "noMandatory", "helper", "idForm", "classes");
         foreach ($pParams as $np => $vp) {
             if (in_array($np, $s)) {
                 continue;
             }
             $n[$np] = $vp;
         }
         $pParams = $n;
         $output .= '<form action="' . Core::rewriteURL($controller, $action, $pParams, Application::getInstance()->currentLanguage) . '" method="post"';
         if ($this->hasUpload) {
             $output .= ' enctype="multipart/form-data"';
         }
         if (!empty($idForm)) {
             $output .= ' id="' . $idForm . '" ';
         }
         if (!empty($classes)) {
             $output .= ' class="' . $classes . '" ';
         }
         $output .= '>';
     }
     if ($this->countMendatory > 0 && !$noMandatory) {
         $output .= "<div class='mandatory'>*&nbsp;";
         if ($this->countMendatory == 1) {
             $output .= Dictionary::term("global.forms.inputRequire");
         } else {
             $output .= Dictionary::term("global.forms.inputsRequire");
         }
         $output .= "</div>";
     }
     foreach ($this->data as $n => $d) {
         $require = "";
         if ($d["require"] == true) {
             $require = "*";
         }
         if (!isset($d["tag"])) {
             continue;
         }
         if ($d["tag"] == "input" && $d["attributes"]["type"] == "file") {
             $d["tag"] = self::TAG_UPLOAD;
         }
         $id = "inp_" . $this->name . "_" . $n;
         if (strrpos($n, "[") > -1) {
             $n = str_replace("[", "][", $n);
             $name = $this->name . "[" . $n;
         } else {
             $name = $this->name . "[" . $n . "]";
         }
         $d["form_name"] = $this->name;
         $d["field_name"] = $n;
         if (call_user_func_array(array($helper, "has"), array($d["tag"]))) {
             $output .= call_user_func_array($helper . "::get", array($d["tag"], array($name, $id, $d, $require)));
         }
     }
     if (!$noForm) {
         $output .= "</form>";
     }
     if ($pReturn == true) {
         return $output;
     }
     echo $output;
 }