本文整理匯總了PHP中templates::render_snippets方法的典型用法代碼示例。如果您正苦於以下問題:PHP templates::render_snippets方法的具體用法?PHP templates::render_snippets怎麽用?PHP templates::render_snippets使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類templates
的用法示例。
在下文中一共展示了templates::render_snippets方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: microtime
<?php
$exec_start = microtime(true);
if (!defined("WALAFUNT_ENTRY_POINT")) {
exit("This script isn't meant to be run directly.");
}
$params = utils::apply_default_params($_GET, ["language" => "all", "tags" => "all", "sort" => "timestamp", "sort_dir" => "asc", "page" => "1"]);
$tags = array_map("trim", explode(",", $params["tags"]));
if ($params["language"] == "all") {
$params["language"] = "*";
}
if ($params["tags"] == "all") {
$params["tags"] = "*";
}
$offset = ($params["page"] - 1) * $settings->snippets_per_page;
$snippets = sqlite_gateway::query("select * from code_snippets; limit {$settings->snippets_per_page} offset {$offset};");
if ($snippets === false) {
// Make sure that the return of the query is always iterable
$snippets = [];
}
$tag_str = templates::format_tags($tags);
$components = ["{prefix}" => ucwords(($params["tags"] == "*" ? "" : $tags_str . " - ") . ($params["language"] == "*" ? "all snippets" : $params["language"] . " - ")), "{code-snippets-list}" => templates::render_snippets($snippets), "{user-panel}" => templates::render_user_panel(env::$username, env::$role)];
header("x-time-taken: " . (microtime(true) - $exec_start));
echo templates::render_html("main.html", $components);