function smarty_function_requestToUrl($params, &$smarty) { /* Convert Request to url, return the url string parameter ignore(str,optional): ignore this key in request, can be a list of keys, seperated by "," */ $ignore_arr = array(); if (isset($params["ignore"])) { $ignore_arr = split($params["ignore"], ","); } return $_SERVER["PHP_SELF"] . "?" . convertRequestToUrl($ignore_arr); }
function smarty_function_reportPages($params, &$smarty) { /* parameter total_results(integer,requrired): total number of results parameter file_path(string,optional): set the file path that will be used in page urls parameter pages_to_show(integer,optional): set number of pages we want to show the user on page select, default 12 */ $url_params = convertRequestToUrl(array("page")); $file_path = isset($params["file_path"]) ? $params["file_path"] : $_SERVER["PHP_SELF"]; $pages_to_show = isset($params["pages_to_show"]) ? (int) $params["pages_to_show"] : 12; $total_pages = calcTotalPages($params["total_results"], getRPP()); $cur_page = min(getCurrentPage(), $total_pages); $link = "{$file_path}?{$url_params}"; $pages = createReportPagesArray($link, $cur_page, $total_pages, $pages_to_show); return createReportPagesTable($pages, $cur_page, $link, $total_pages); }
function smarty_block_sortableHeader($params, $content, &$smarty, &$repeat) { /* Create a Sortable header, used for reports. this is done by making a new request link, with order_by and desc attribute values changed. parameter name(string,required): name that will be present in order_by if our link clicked parameter default(string,optional): if set to TRUE and order_by is not present in request, we assume we're the default order by parameter default_desc(string,optional): defaultly! are we desc? */ if (!is_null($content)) { $request_url = $_SERVER["PHP_SELF"] . "?" . convertRequestToUrl(array("order_by", "desc")); $ret = ""; $desc = "&desc=1"; if (isInRequest("order_by") and $_REQUEST["order_by"] == $params["name"]) { $ret .= currentSortImage(isInRequest("desc")); if (isInRequest("desc")) { $desc = ""; } } else { if (!isInRequest("order_by") and isset($params["default"]) and $params["default"] == "TRUE") { $ret .= currentSortImage($params["default_desc"] == "TRUE"); if ($params["default_desc"] == "TRUE") { $desc = ""; } } } $ret .= <<<END <a class="Header_Top_links" href="{$request_url}&order_by={$params["name"]}{$desc}"> \t{$content} </a> END; return $ret; } }