本文整理汇总了PHP中item::root方法的典型用法代码示例。如果您正苦于以下问题:PHP item::root方法的具体用法?PHP item::root怎么用?PHP item::root使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::root方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_test
public function delete_test()
{
$tag = tag::add(item::root(), "tag1")->reload();
$request->url = rest::url("tag_item", $tag, item::root());
tag_item_rest::delete($request);
$this->assert_false($tag->reload()->has(item::root()));
}
示例2: get_test
public function get_test()
{
$t1 = tag::add(item::root(), "t1");
$t2 = tag::add(item::root(), "t2");
$request = new stdClass();
$this->assert_equal_array(array("url" => rest::url("tags"), "members" => array(rest::url("tag", $t1), rest::url("tag", $t2))), tags_rest::get($request));
}
示例3: get_test
public function get_test()
{
$tag = tag::add(item::root(), "tag1")->reload();
$request = new stdClass();
$request->url = rest::url("tag", $tag);
$this->assert_equal_array(array("url" => rest::url("tag", $tag), "entity" => $tag->as_array(), "relationships" => array("items" => array("url" => rest::url("tag_items", $tag), "members" => array(rest::url("tag_item", $tag, item::root()))))), tag_rest::get($request));
}
示例4: change
public function change()
{
access::verify_csrf();
$active_provider = module::get_var("gallery", "identity_provider", "user");
$providers = identity::providers();
$new_provider = Input::instance()->post("provider");
if ($new_provider != $active_provider) {
module::deactivate($active_provider);
// Switch authentication
identity::reset();
module::set_var("gallery", "identity_provider", $new_provider);
module::install($new_provider);
module::activate($new_provider);
module::event("identity_provider_changed", $active_provider, $new_provider);
module::uninstall($active_provider);
message::success(t("Changed to %description", array("description" => $providers->{$new_provider})));
try {
Session::instance()->destroy();
} catch (Exception $e) {
// We don't care if there was a problem destroying the session.
}
url::redirect(item::root()->abs_url());
}
message::info(t("The selected provider \"%description\" is already active.", array("description" => $providers->{$new_provider})));
url::redirect("admin/identity");
}
示例5: index
public function index()
{
if (isset($_GET['cw'])) {
setcookie('cw_agree', '1', time() + 60 * 60 * 24, '/');
url::redirect(item::root()->abs_url());
}
}
示例6: create_comment_for_user_test
public function create_comment_for_user_test()
{
$admin = identity::admin_user();
$comment = ORM::factory("comment");
$comment->item_id = item::root()->id;
$comment->text = "text";
$comment->author_id = $admin->id;
$comment->save();
$this->assert_equal($admin->full_name, $comment->author_name());
$this->assert_equal($admin->email, $comment->author_email());
$this->assert_equal($admin->url, $comment->author_url());
$this->assert_equal("text", $comment->text);
$this->assert_equal(1, $comment->item_id);
$this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
$this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
$this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
$this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
$this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
$this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
$this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
$this->assert_equal("HTTP_HOST", $comment->server_http_host);
$this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
$this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
$this->assert_equal("QUERY_STRING", $comment->server_query_string);
$this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
$this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
$this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
$this->assert_true(!empty($comment->created));
}
示例7: site_menu
static function site_menu($menu, $theme)
{
if ($theme->page_type != "login") {
$menu->append(Menu::factory("link")->id("home")->label(t("Home"))->url(item::root()->url()));
$item = $theme->item();
$can_edit = $item && access::can("edit", $item);
$can_add = $item && access::can("add", $item);
if ($can_add) {
$menu->append($add_menu = Menu::factory("submenu")->id("add_menu")->label(t("Add")));
$add_menu->append(Menu::factory("dialog")->id("add_photos_item")->label(t("Add photos"))->url(url::site("simple_uploader/app/{$item->id}")));
if ($item->is_album()) {
$add_menu->append(Menu::factory("dialog")->id("add_album_item")->label(t("Add an album"))->url(url::site("form/add/albums/{$item->id}?type=album")));
}
}
$menu->append($options_menu = Menu::factory("submenu")->id("options_menu")->label(t("Photo options")));
if ($item && ($can_edit || $can_add)) {
if ($can_edit) {
$options_menu->append(Menu::factory("dialog")->id("edit_item")->label($item->is_album() ? t("Edit album") : t("Edit photo"))->url(url::site("form/edit/{$item->type}s/{$item->id}")));
}
if ($item->is_album()) {
$options_menu->label(t("Album options"));
if ($can_edit) {
$options_menu->append(Menu::factory("dialog")->id("edit_permissions")->label(t("Edit permissions"))->url(url::site("permissions/browse/{$item->id}")));
}
}
}
if (user::active()->admin) {
$menu->append($admin_menu = Menu::factory("submenu")->id("admin_menu")->label(t("Admin")));
gallery::admin_menu($admin_menu, $theme);
module::event("admin_menu", $admin_menu, $theme);
}
module::event("site_menu", $menu, $theme);
}
}
示例8: show
public function show($page_name)
{
// Display the page specified by $page_name, or a 404 error if it doesn't exist.
// Run a database search to look up the page.
$existing_page = ORM::factory("px_static_page")->where("name", "=", $page_name)->find_all();
// If it doesn't exist, display a 404 error.
if (count($existing_page) == 0) {
throw new Kohana_404_Exception();
}
// Set up breadcrumbs.
$breadcrumbs = array();
$root = item::root();
$breadcrumbs[] = Breadcrumb::instance($root->title, $root->url())->set_first();
$breadcrumbs[] = Breadcrumb::instance(t($existing_page[0]->title), url::site("pages_xtra/show/{$page_name}"))->set_last();
// Display the page.
$template = new Theme_View("page.html", "other", "Pages");
$template->set_global(array("breadcrumbs" => $breadcrumbs));
// Call database variables into page header (off-page content).
$site_title = module::get_var("pages_xtra", "site_title");
// Next line can be used as alternative to the following line
// $template->page_title = t("Gallery :: ") . t($existing_page[0]->title);
$template->page_title = t($existing_page[0]->title) . t(" :: {$site_title}");
$template->page_tags = $existing_page[0]->tags;
$page_tags = trim(nl2br(html::purify($existing_page[0]->tags)));
$template->page_description = $existing_page[0]->description;
$page_description = trim(nl2br(html::purify($existing_page[0]->description)));
// Set a new View and call database variables into page (on-page content).
$template->content = new View("pages_xtra_display.html");
$template->content->title = $existing_page[0]->title;
$template->content->body = $existing_page[0]->html_code;
print $template;
}
示例9: user_created
/**
* Create an album for the newly created user and give him view and edit permissions.
*/
static function user_created($user)
{
// Create a group with the same name, if necessary
$group_name = "auto: {$user->name}";
$group = identity::lookup_group_by_name($group_name);
if (!$group) {
$group = identity::create_group($group_name);
identity::add_user_to_group($user, $group);
}
// Create an album for the user, if it doesn't exist
$album = ORM::factory("item")->where("parent_id", "=", item::root()->id)->where("name", "=", $user->name)->find();
if (!$album->loaded()) {
$album->type = "album";
$album->name = $user->name;
$album->title = "{$user->name}'s album";
$album->parent_id = item::root()->id;
$album->sort_column = "weight";
$album->sort_order = "asc";
$album->save();
access::allow($group, "view", item::root());
access::allow($group, "view_full", $album);
access::allow($group, "edit", $album);
access::allow($group, "add", $album);
}
}
示例10: feed
static function feed($feed_id, $offset, $limit, $id)
{
$feed = new stdClass();
switch ($feed_id) {
case "latest":
$feed->items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC")->find_all($limit, $offset);
$all_items = ORM::factory("item")->viewable()->where("type", "<>", "album")->order_by("created", "DESC");
$feed->max_pages = ceil($all_items->find_all()->count() / $limit);
$feed->title = t("%site_title - Recent updates", array("site_title" => item::root()->title));
$feed->description = t("Recent updates");
return $feed;
case "album":
$item = ORM::factory("item", $id);
access::required("view", $item);
$feed->items = $item->viewable()->descendants($limit, $offset, array(array("type", "=", "photo")));
$feed->max_pages = ceil($item->viewable()->descendants_count(array(array("type", "=", "photo"))) / $limit);
if ($item->id == item::root()->id) {
$feed->title = html::purify($item->title);
} else {
$feed->title = t("%site_title - %item_title", array("site_title" => item::root()->title, "item_title" => $item->title));
}
$feed->description = nl2br(html::purify($item->description));
return $feed;
}
}
示例11: map
/**
* Redirect Gallery 2 urls to their appropriate matching Gallery 3 url.
*
* We use mod_rewrite to create this path, so Gallery2 urls like this:
* /gallery2/v/Family/Wedding.jpg.html
* /gallery2/main.php?g2_view=core.ShowItem&g2_itemId=1234
*
* Show up here like this:
* /g2/map?path=v/Family/Wedding.jpg.html
* /g2/map?g2_view=core.ShowItem&g2_itemId=1931
*/
public function map()
{
$input = Input::instance();
$path = $input->get("path");
$id = $input->get("g2_itemId");
if ($path && $path != 'index.php' && $path != 'main.php' || $id) {
if ($id) {
// Requests by id are either core.DownloadItem or core.ShowItem requests. Later versions of
// Gallery 2 don't specify g2_view if it's the default (core.ShowItem). And in some cases
// (bbcode, embedding) people are using the id style URLs although URL rewriting is enabled.
$where = array(array("g2_id", "=", $id));
$view = $input->get("g2_view");
if ($view == "core.DownloadItem") {
$where[] = array("resource_type", "IN", array("file", "resize", "thumbnail", "full"));
} else {
if ($view) {
$where[] = array("g2_url", "like", "%g2_view={$view}%");
}
}
// else: Assuming that the first search hit is sufficiently good.
} else {
if ($path) {
$where = array(array("g2_url", "IN", array($path, str_replace(" ", "+", $path))));
} else {
throw new Kohana_404_Exception();
}
}
$g2_map = ORM::factory("g2_map")->merge_where($where)->find();
if (!$g2_map->loaded()) {
throw new Kohana_404_Exception();
}
$item = ORM::factory("item", $g2_map->g3_id);
if (!$item->loaded()) {
throw new Kohana_404_Exception();
}
$resource_type = $g2_map->resource_type;
} else {
$item = item::root();
$resource_type = "album";
}
access::required("view", $item);
// Redirect the user to the new url
switch ($resource_type) {
case "thumbnail":
url::redirect($item->thumb_url(true));
case "resize":
url::redirect($item->resize_url(true));
case "file":
case "full":
url::redirect($item->file_url(true));
case "item":
case "album":
url::redirect($item->abs_url());
case "group":
case "user":
default:
throw new Kohana_404_Exception();
}
}
示例12: post_test
public function post_test()
{
access::allow(identity::everybody(), "edit", item::root());
$request = new stdClass();
$request->params = new stdClass();
$request->params->name = "test tag";
$this->assert_equal(array("url" => url::site("rest/tag/1")), tags_rest::post($request));
}
示例13: index
public function index()
{
access::verify_csrf();
auth::logout();
if ($continue_url = Input::instance()->get("continue_url")) {
url::redirect($continue_url);
}
url::redirect(item::root()->abs_url());
}
示例14: index
public function index()
{
if (!user::active()->admin) {
url::redirect(item::root()->abs_url());
}
$v = new View("welcome_message.html");
$v->user = user::active();
print $v;
}
示例15: auth_html
public function auth_html()
{
access::verify_csrf();
list($valid, $form) = $this->_auth("login/auth_html");
if ($valid) {
url::redirect(item::root()->abs_url());
} else {
print $form;
}
}