本文整理汇总了PHP中Settings::getRootInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getRootInstance方法的具体用法?PHP Settings::getRootInstance怎么用?PHP Settings::getRootInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Settings
的用法示例。
在下文中一共展示了Settings::getRootInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCode
/**
*
* @return string
*/
public function getCode()
{
if (isset($_POST['save'])) {
foreach ($_POST as $property => $value) {
if ($property != "save" && $property != "roles") {
$settings = Settings::getRootInstance()->specify($this->areaType, $this->area);
if ($this->dir != "" && $this->dir != "/") {
$settings = $settings->dir($this->dir);
}
$settings->set($property, $value, $this->role);
}
}
Settings::forceReload();
Cache::clear();
Language::GetGlobal()->ClearCache();
if (@header("Location:" . str_replace("&save_settings=1", "", $_SERVER['REQUEST_URI']))) {
exit;
} else {
die("<script>window.location.href = '" . str_replace("&save_settings=1", "", $_SERVER['REQUEST_URI']) . "';</script>");
}
$changed = true;
}
$template = new Template();
$template->load($this->template);
if ($this->area != "global" || $this->areaType != "global") {
$roleselector = "<select name=\"roles\" onchange=\"document.location.href='" . $this->url . $this->getQuerySeperator() . "areatype=" . urlencode($this->areaType) . "&area=" . urlencode($this->area) . "&role=' + this.options[this.selectedIndex].value + '&save_settings=1';\">";
} else {
$roleselector = "<select name=\"roles\" onchange=\"document.location.href='" . $this->url . $this->getQuerySeperator() . "role=' + this.options[this.selectedIndex].value + '&save_settings=1';\">";
}
$roles = DataBase::Current()->ReadRows("SELECT * FROM {'dbprefix'}roles ORDER BY name");
if ($roles) {
foreach ($roles as $role) {
if ($this->role == $role->id) {
$roleselector .= "<option value=\"" . $role->id . "\" selected=\"selected\">" . htmlentities($role->name) . "</option>";
} else {
$roleselector .= "<option value=\"" . $role->id . "\">" . $role->name . "</option>";
}
}
}
$roleselector .= "</select>";
$template->assign_var("ROLES", $roleselector);
if ($this->area != "global" || $this->areaType != "global") {
$template->assign_var("URL", $this->url . $this->getQuerySeperator() . "areatype=" . urlencode($this->areaType) . "&area=" . urlencode($this->area) . "&role=" . $this->role . "&save_settings=1");
} else {
$template->assign_var("URL", $this->url . $this->getQuerySeperator() . "role=" . $this->role . "&save_settings=1");
}
$rows = Settings::getRootInstance()->specify($this->areaType, $this->area)->dir($this->dir)->getRows($this->role);
if ($rows) {
foreach ($rows as $row) {
$index = $template->add_loop_item("SETTINGS");
$template->assign_loop_var("SETTINGS", $index, "PROPERTY", $row['name']);
$template->assign_loop_var("SETTINGS", $index, "DESCRIPTION", htmlentities($row['description']));
$control = new $row['type']();
$control->name = $row['name'];
$control->value = $row['value'];
$template->assign_loop_var("SETTINGS", $index, "CONTROL", $control->getCode());
}
}
return $template->getCode();
}
示例2: getEditableCode
public function getEditableCode()
{
Cache::clear();
$change = htmlentities(Language::GetGlobal()->getString("CHANGE"));
$plugin_contactform_res = "<h3>" . Language::DirectTranslate("plugin_contactform_pagetypetitle") . "</h3>";
$settings = Settings::getRootInstance()->specify("plugin", "contactform");
if ($settings->get("contactform_mail") == "") {
$plugin_contactform_res .= "<p><a href=\"" . Settings::getInstance()->get("host") . "admin/pluginsettings.html?plugin=contactform\">" . Language::DirectTranslate("plugin_contactform_nomailfound") . "</a></p>";
}
$plugin_contactform_res .= "<input name=\"save\" type=\"submit\" value=\"" . $change . "\" onclick=\"form.action='" . UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $this->page->alias) . "' ; target='_self' ; return true\" />";
return $plugin_contactform_res;
}
示例3: Template
<?php
Cache::clear();
$settings = Settings::getRootInstance()->specify("plugin", "contactform");
$plugin_contactform_mail = $settings->get("contactform_mail");
$plugin_contactform_successmessage = $settings->get("contactform_successmessage");
if (isset($_POST['mail'])) {
Cache::clear();
if ($plugin_contactform_mail != $_POST['mail']) {
$settings->set("contactform_mail", $_POST['mail']);
}
if ($plugin_contactform_successmessage != $_POST['successmessage']) {
$settings->set("contactform_successmessage", $_POST['successmessage']);
}
$plugin_contactform_mail = $_POST['mail'];
$plugin_contactform_successmessage = $_POST['successmessage'];
Settings::forceReload();
echo Language::DirectTranslate("plugin_contactform_plugincontactformsaved");
}
$template = new Template();
$template->load("plugin_contactform_settings");
$template->assign_var("mail", htmlentities($plugin_contactform_mail));
$template->assign_var("successmessage", htmlentities($plugin_contactform_successmessage));
$template->output();
示例4: Template
<?php
$settings = Settings::getRootInstance()->specify("plugin", "analytics");
$template = new Template();
if ($settings->get("analytics_system") == "google" && $settings->get("analytics_value") != "") {
$template->load("plugin_analytics_google");
$template->assign_var("UAID", $settings->get("analytics_value"));
$template->assign_var("DOMAINNAME", Settings::getInstance()->get("host"));
$template->output();
} elseif ($settings->get("analytics_system") == "piwik" && $settings->get("analytics_value") != "") {
$template->load("plugin_analytics_piwik");
$plugin_analytics_piwikurl = $settings->get("analytics_value");
if (substr($plugin_analytics_piwikurl, -5) == "https") {
$plugin_analytics_piwikurl = substr($plugin_analytics_piwikurl, 5);
} else {
$plugin_analytics_piwikurl = substr($plugin_analytics_piwikurl, 4);
}
$template->assign_var("PIWIKURL", $plugin_analytics_piwikurl);
$template->output();
}
示例5: display
//.........这里部分代码省略.........
$page->inSitemap = false;
}
$page->priority = $_POST['priority'];
$page->save();
$page->getEditor()->save($page, $oldpage);
Role::clearAccess($page);
if ($_POST['rights']) {
foreach ($_POST['rights'] as $right) {
$role = new Role();
$role->load($right);
$role->allowAccess($page);
}
}
} else {
if (isset($_POST['menu'])) {
$page->title = $_POST['title'];
$page->alias = $page->getDir() . $_POST['localalias'];
$page->menu = $_POST['menu'];
$page->getEditor()->content = $_POST['content'];
}
}
$url = UrlRewriting::GetUrlByAlias("admin/pageedit", "site=" . $page->alias);
$template->assign_var("PATH", $url);
$template->assign_var("ALIAS", $page->alias);
$template->assign_var("LOCALALIAS", $page->getLocalAlias());
if (!isset($_POST['menu'])) {
foreach (Role::getAllRoles() as $role) {
$index = $template->add_loop_item("RIGHTS");
$template->assign_loop_var("RIGHTS", $index, "LABEL", "/");
$template->assign_loop_var("RIGHTS", $index, "VALUE", $role->ID);
$template->assign_loop_var("RIGHTS", $index, "NAME", $role->name);
if ($role->canAccess($page)) {
$template->assign_loop_var("RIGHTS", $index, "SELECTED", "selected=\"1\" ");
} else {
$template->assign_loop_var("RIGHTS", $index, "SELECTED", "");
}
}
} else {
foreach (Role::getAllRoles() as $role) {
$index = $template->add_loop_item("RIGHTS");
$template->assign_loop_var("RIGHTS", $index, "LABEL", "/");
$template->assign_loop_var("RIGHTS", $index, "VALUE", $role->ID);
$template->assign_loop_var("RIGHTS", $index, "NAME", $role->name);
if (isset($_POST['rights']) && in_array($role->ID, $_POST['rights'])) {
$template->assign_loop_var("RIGHTS", $index, "SELECTED", "selected=\"1\" ");
} else {
$template->assign_loop_var("RIGHTS", $index, "SELECTED", "");
}
}
}
$index = $template->add_loop_item("MENU");
$template->assign_loop_var("MENU", $index, "VALUE", "0");
$template->assign_loop_var("MENU", $index, "NAME", "-- " . Language::DirectTranslate("NO_MENU") . " --");
$template->assign_loop_var("MENU", $index, "SELECTED", "");
foreach (sys::getMenues($_SESSION['dir']) as $menu) {
$index = $template->add_loop_item("MENU");
$template->assign_loop_var("MENU", $index, "VALUE", $menu->id);
$template->assign_loop_var("MENU", $index, "NAME", $menu->name);
if (isset($_POST['menu']) && $_POST['menu'] == $menu->id) {
$template->assign_loop_var("MENU", $index, "SELECTED", "selected=\"1\" ");
} else {
if (!isset($_POST['menu']) && $menu->id == $page->menu) {
$template->assign_loop_var("MENU", $index, "SELECTED", "selected=\"1\" ");
} else {
$template->assign_loop_var("MENU", $index, "SELECTED", "");
}
}
}
if (isset($_POST['menu'])) {
$template->assign_var("MENUPREVIEW", Menu::getCode($_POST['menu'], "<ul>", "</ul>", "<li>", "</li>", ""));
} else {
if ($page->menu > 0) {
$template->assign_var("MENUPREVIEW", Menu::getCode($page->menu, "<ul>", "</ul>", "<li>", "</li>", ""));
} else {
$template->assign_var("MENUPREVIEW", "");
}
}
$template->assign_var("METADESCRIPTION", htmlentities($page->getMeta()->description));
$template->assign_var("METAKEYWORDS", htmlentities($page->getMeta()->keywords));
$template->assign_var("METAROBOTS", htmlentities($page->getMeta()->robots));
$template->assign_var("CANONICAL", $page->canonical);
$template->assign_var("ADVANCED_HTML_HEADER", htmlentities($page->advancedHtmlHeader));
$template->assign_var("TITLE", $page->title);
$template->assign_var("EDITOR", $page->getEditor()->getEditableCode());
$template->assign_var("HOST", Settings::getRootInstance()->dir($page->alias . "§page")->get("host") . $page->getDir());
$template->assign_var("CHANGE_FREQUENCE", $page->GetChangeFrequence());
$template->assign_var("PRIORITY", $page->priority);
if ($page->inSitemap) {
$template->assign_var("IN_SITEMAP_CHECKED", " checked=\"checked\"");
} else {
$template->assign_var("IN_SITEMAP_CHECKED", "");
}
$selector = new PageSelector();
$selector->name = 'owner';
$selector->value = $page->ownerid;
$selector->noValueText = "-- " . Language::DirectTranslate("NOOWNER") . " --";
$template->assign_var("OWNERCONTROL", $selector->getCode());
$template->output();
}
}