本文整理汇总了PHP中Section::by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Section::by_id方法的具体用法?PHP Section::by_id怎么用?PHP Section::by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_backend_subactions
function build_backend_subactions()
{
global $backend_subactions, $pluginpages_handlers;
$backend_subactions = url_action_subactions(array("_index" => url_action_alias(array("login")), "index" => url_action_alias(array("login")), "_prelude" => function (&$data, $url_now, &$url_next) {
global $ratatoeskr_settings, $admin_grp, $ste, $languages;
if ($admin_grp === NULL) {
$admin_grp = Group::by_name("admins");
}
$ste->vars["all_languages"] = array();
$ste->vars["all_langcodes"] = array();
foreach ($languages as $code => $data) {
$ste->vars["all_languages"][$code] = $data["language"];
$ste->vars["all_langcodes"][] = $code;
}
ksort($ste->vars["all_languages"]);
sort($ste->vars["all_langcodes"]);
/* Check authentification */
if (isset($_SESSION["ratatoeskr_uid"])) {
try {
$user = User::by_id($_SESSION["ratatoeskr_uid"]);
if ($user->pwhash == $_SESSION["ratatoeskr_pwhash"] and $user->member_of($admin_grp)) {
if (empty($user->language)) {
$user->language = $ratatoeskr_settings["default_language"];
$user->save();
}
load_language($user->language);
if ($url_next[0] == "login") {
$url_next = array("content", "write");
}
$data["user"] = $user;
$ste->vars["user"] = array("id" => $user->get_id(), "name" => $user->username, "lang" => $user->language);
return;
/* Authentification successful, continue */
} else {
unset($_SESSION["ratatoeskr_uid"]);
}
} catch (DoesNotExistError $e) {
unset($_SESSION["ratatoeskr_uid"]);
}
}
load_language();
/* If we are here, user is not logged in... */
$url_next = array("login");
}, "login" => url_action_simple(function ($data) {
global $ste, $admin_grp;
if (!empty($_POST["user"])) {
try {
$user = User::by_name($_POST["user"]);
if (!PasswordHash::validate($_POST["password"], $user->pwhash)) {
throw new Exception();
}
if (!$user->member_of($admin_grp)) {
throw new Exception();
}
/* Login successful. */
$_SESSION["ratatoeskr_uid"] = $user->get_id();
$_SESSION["ratatoeskr_pwhash"] = $user->pwhash;
load_language($user->language);
$data["user"] = $user;
$ste->vars["user"] = array("id" => $user->get_id(), "name" => $user->username, "lang" => $user->language);
} catch (Exception $e) {
$ste->vars["login_failed"] = True;
}
if (isset($data["user"])) {
throw new Redirect(array("content", "write"));
}
}
echo $ste->exectemplate("/systemtemplates/backend_login.html");
}), "logout" => url_action_simple(function ($data) {
unset($_SESSION["ratatoeskr_uid"]);
unset($_SESSION["ratatoeskr_pwhash"]);
load_language();
throw new Redirect(array("login"));
}), "content" => url_action_subactions(array("write" => function (&$data, $url_now, &$url_next) {
global $ste, $translation, $textprocessors, $ratatoeskr_settings, $languages, $articleeditor_plugins;
list($article, $editlang) = array_slice($url_next, 0);
if (!isset($editlang)) {
$editlang = $data["user"]->language;
}
if (isset($article)) {
$ste->vars["article_editurl"] = urlencode($article) . "/" . urlencode($editlang);
} else {
$ste->vars["article_editurl"] = "";
}
$url_next = array();
$default_section = Section::by_id($ratatoeskr_settings["default_section"]);
$ste->vars["section"] = "content";
$ste->vars["submenu"] = isset($article) ? "articles" : "newarticle";
$ste->vars["textprocessors"] = array();
foreach ($textprocessors as $txtproc => $properties) {
if ($properties[1]) {
$ste->vars["textprocessors"][] = $txtproc;
}
}
$ste->vars["sections"] = array();
foreach (Section::all() as $section) {
$ste->vars["sections"][] = $section->name;
}
$ste->vars["article_section"] = $default_section->name;
/* Check Form */
//.........这里部分代码省略.........
示例2: get_section
public function get_section()
{
if ($this->section_obj === NULL) {
$this->section_obj = Section::by_id($this->section_id);
}
return $this->section_obj;
}
示例3: frontend_url_handler
function frontend_url_handler(&$data, $url_now, &$url_next)
{
global $ste, $ratatoeskr_settings, $languages, $metasections, $comment_validators, $on_comment_store;
$path = array_merge(array($url_now), $url_next);
$url_next = array();
/* If no language or an invalid language was given, fix it. */
if (count($path) == 0 or !isset($languages[$path[0]])) {
if (count($path > 0)) {
array_shift($path);
}
array_unshift($path, $ratatoeskr_settings["default_language"]);
}
$ste->vars["current"]["url_fragments"] = $path;
$lang = array_shift($path);
$ste->vars["language"] = $lang;
load_language($languages[$lang]["translation_exist"] ? $lang : "en");
/* English is always available */
if (count($path) != 0) {
$section_name = array_shift($path);
} else {
$section_name = NULL;
}
if ($section_name == "_tags") {
try {
$tag = Tag::by_name(array_shift($path));
} catch (DoesNotExistError $e) {
throw new NotFoundError();
}
$ste->vars["current"]["tag"] = tag_transform_ste($tag, $lang);
} else {
if ($section_name === NULL) {
$section = Section::by_id($ratatoeskr_settings["default_section"]);
} else {
try {
$section = Section::by_name($section_name);
} catch (DoesNotExistError $e) {
throw new NotFoundError();
}
}
if (count($path) == 0) {
$ste->vars["current"]["section"] = section_transform_ste($section, $lang);
} else {
try {
$article = Article::by_urlname(array_shift($path));
} catch (DoesNotExistError $e) {
throw new NotFoundError();
}
$ste->vars["current"]["article"] = article_transform_ste($article, $lang);
if (isset($_GET["comment"])) {
if (isset($_POST["preview_comment"])) {
$ste->vars["current"]["comment_prev"] = Comment::htmlize_comment_text($_POST["comment_text"]);
} else {
if (isset($_POST["post_comment"])) {
$rejected = False;
try {
foreach ($comment_validators as $validator) {
call_user_func($validator);
}
} catch (CommentRejected $e) {
$ste->vars["current"]["comment_fail"] = htmlesc($e->getMessage());
$rejected = True;
}
if (!$rejected) {
$comment = Comment::create($article, $lang);
$comment->author_name = $_POST["author_name"];
$comment->author_mail = $_POST["author_mail"];
$comment->text = $_POST["comment_text"];
$comment->save();
$ste->vars["current"]["commented"] = "Yes";
foreach ($on_comment_store as $ocs_fx) {
call_user_func($ocs_fx, $comment);
}
}
}
}
}
}
}
$ste->vars["current"]["page"] = (isset($_GET["page"]) and is_numeric($_GET["page"])) ? $_GET["page"] : 1;
if (!isset($section)) {
$section = Section::by_id($ratatoeskr_settings["default_section"]);
}
foreach ($section->get_styles() as $style) {
$ste->vars["current"]["styles"][] = $style->name;
$ste->vars["current"]["__style_objs"][] = $style;
}
echo $ste->exectemplate("/usertemplates/" . $section->template);
}