本文整理汇总了PHP中Style::by_name方法的典型用法代码示例。如果您正苦于以下问题:PHP Style::by_name方法的具体用法?PHP Style::by_name怎么用?PHP Style::by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Style
的用法示例。
在下文中一共展示了Style::by_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
global $rel_path_to_root;
if (isset($params["mode"]) and ($params["mode"] == "embed" or $params["mode"] == "link")) {
$mode = $params["mode"];
} else {
$mode = "link";
}
if ($mode == "embed") {
$output = "";
if (isset($ste->vars["current"]["__style_objs"])) {
foreach ($ste->vars["current"]["__style_objs"] as $style) {
$output .= "/* Style: {$style->name} */\n" . $style->code . "\n";
}
} else {
foreach ($ste->vars["current"]["styles"] as $stylename) {
try {
$style = Style::by_name($stylename);
$output .= "/* Style: {$stylename} */\n" . str_replace("%root%", $rel_path_to_root, $style->code) . "\n";
} catch (DoesNotExistError $e) {
$output .= "/* Warning: Failed to load style: {$stylename} */\n";
}
}
}
$output = "<style type=\"text/css\">\n" . htmlesc($output) . "</style>";
} else {
$output = "";
foreach ($ste->vars["current"]["styles"] as $stylename) {
$output .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"{$rel_path_to_root}/css.php?name=" . htmlesc($stylename) . "\" />\n";
}
}
return $output;
});
示例2: 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 */
//.........这里部分代码省略.........
示例3: dirname
<?php
/*
* File: css.php
* Spit out User-defined CSS styles.
*
* License:
* This file is part of Ratatöskr.
* Ratatöskr is licensed unter the MIT / X11 License.
* See "ratatoeskr/licenses/ratatoeskr" for more information.
*/
require_once dirname(__FILE__) . "/ratatoeskr/sys/models.php";
if (!isset($_GET["name"])) {
die;
}
try {
$style = Style::by_name($_GET["name"]);
header("Content-Type: text/css; charset=UTF-8");
echo str_replace("%root%", ".", $style->code);
} catch (DoesNotExistError $e) {
header("HTTP/1.1 404 Not Found");
header("Content-Type: text/plain; charset=UTF-8");
echo "404 - Not found.";
}