本文整理汇总了PHP中item::move方法的典型用法代码示例。如果您正苦于以下问题:PHP item::move方法的具体用法?PHP item::move怎么用?PHP item::move使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::move方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save($source_id)
{
access::verify_csrf();
$source = ORM::factory("item", $source_id);
$target = ORM::factory("item", $this->input->post("target_id"));
item::move($source, $target);
print json_encode(array("result" => "success", "location" => url::site("albums/{$target->id}")));
}
示例2: save
public function save($source_id)
{
access::verify_csrf();
$source = ORM::factory("item", $source_id);
$target = ORM::factory("item", $this->input->post("target_id"));
access::required("view", $source);
access::required("edit", $source);
access::required("view", $target);
access::required("edit", $target);
item::move($source, $target);
print json_encode(array("result" => "success", "location" => $target->url()));
}
示例3: move_to
function move_to($target_album_id)
{
access::verify_csrf();
$target_album = ORM::factory("item", $target_album_id);
foreach ($this->input->post("source_ids") as $source_id) {
$source = ORM::factory("item", $source_id);
if (!$source->contains($target_album)) {
item::move($source, $target_album);
}
}
print json_encode(array("tree" => self::_expanded_tree(ORM::factory("item", 1), $album)->__toString(), "grid" => self::_get_micro_thumb_grid($album, 0)->__toString()));
}
示例4: run
static function run($task)
{
$context = unserialize($task->context);
$taskType = $context["type"];
try {
$target = ORM::factory("item", $context["target"]);
$total = count($context["items"]);
$stop = min($total - $context["position"], $context["batch"]);
$context["post_process"] = array();
for ($offset = 0; $offset < $stop; $offset++) {
$current_id = $context["position"] + $offset;
$id = $context["items"][$current_id];
switch ($taskType) {
case "move":
$source = ORM::factory("item", $id);
item::move($source, $target);
break;
case "rearrange":
Database::instance()->query("Update {items} set weight = {$context["position"]} where id={$id};");
break;
case "rotateCcw":
case "rotateCw":
$item = ORM::factory("item", $id);
if ($item->is_photo()) {
$context["post_process"]["reload"][] = self::_do_rotation($item, $taskType == "rotateCcw" ? -90 : 90);
}
break;
case "albumCover":
item::make_album_cover(ORM::factory("item", $id));
break;
case "delete":
$item = ORM::factory("item", $id);
$item->delete();
$context["post_process"]["remove"][] = array("id" => $id);
break;
default:
throw new Exception("Task '{$taskType}' is not implmented");
}
}
$context["position"] += $stop;
$task->state = "success";
} catch (Exception $e) {
$task->status = $e->getMessage();
$task->state = "error";
$task->save();
throw $e;
}
$task->context = serialize($context);
$total = count($context["items"]);
$task->percent_complete = $context["position"] / (double) $total * 100;
$task->done = $context["position"] == $total || $task->state == "error";
}
示例5: move_to
function move_to($target_album_id)
{
access::verify_csrf();
$target_album = ORM::factory("item", $target_album_id);
access::required("view", $target_album);
access::required("add", $target_album);
foreach (Input::instance()->post("source_ids") as $source_id) {
$source = ORM::factory("item", $source_id);
if (!$source->contains($target_album)) {
access::required("edit", $source);
item::move($source, $target_album);
}
}
print json_encode(array("tree" => self::_expanded_tree(ORM::factory("item", 1), $target_album)->__toString(), "grid" => self::_get_micro_thumb_grid($target_album, 0)->__toString()));
}
示例6: move_to
function move_to($target_album_id)
{
access::verify_csrf();
$target_album = ORM::factory("item", $target_album_id);
$js = json_decode($_REQUEST["sourceids"]);
$i = 0;
foreach ($js as $source_id) {
$source = ORM::factory("item", $source_id);
if (!$source->contains($target_album)) {
item::move($source, $target_album);
}
$i++;
}
print json_encode(array("result" => "success"));
}
示例7: move_to
function move_to($target_album_id)
{
access::verify_csrf();
$target_album = ORM::factory("item", $target_album_id);
access::required("view", $target_album);
access::required("add", $target_album);
$source_album = null;
$js = json_decode($_REQUEST["sourceids"]);
$i = 0;
$source_album = null;
foreach ($js as $source_id) {
$source = ORM::factory("item", $source_id);
if (empty($source_album)) {
// get the source_album
$source_album = $source->parent();
}
if (!$source->contains($target_album)) {
access::required("edit", $source);
item::move($source, $target_album);
}
$i++;
}
json::reply(array("result" => "success"));
}
示例8: moved_items_inherit_new_permissions_test
public function moved_items_inherit_new_permissions_test()
{
identity::set_active_user(identity::lookup_user_by_name("admin"));
$public_album = test::random_album();
$public_photo = test::random_photo($public_album);
access::allow(identity::everybody(), "view", $public_album);
access::allow(identity::everybody(), "edit", $public_album);
item::root()->reload();
// Account for MPTT changes
$private_album = test::random_album();
access::deny(identity::everybody(), "view", $private_album);
access::deny(identity::everybody(), "edit", $private_album);
$private_photo = test::random_photo($private_album);
// Make sure that we now have a public photo and private photo.
$this->assert_true(access::group_can(identity::everybody(), "view", $public_photo));
$this->assert_false(access::group_can(identity::everybody(), "view", $private_photo));
// Swap the photos
item::move($public_photo, $private_album);
$private_album->reload();
// Reload to get new MPTT pointers and cached perms.
$public_album->reload();
$private_photo->reload();
$public_photo->reload();
item::move($private_photo, $public_album);
$private_album->reload();
// Reload to get new MPTT pointers and cached perms.
$public_album->reload();
$private_photo->reload();
$public_photo->reload();
// Make sure that the public_photo is now private, and the private_photo is now public.
$this->assert_false(access::group_can(identity::everybody(), "view", $public_photo));
$this->assert_false(access::group_can(identity::everybody(), "edit", $public_photo));
$this->assert_true(access::group_can(identity::everybody(), "view", $private_photo));
$this->assert_true(access::group_can(identity::everybody(), "edit", $private_photo));
}
示例9: moved_items_inherit_new_permissions_test
public function moved_items_inherit_new_permissions_test()
{
user::set_active(user::lookup_by_name("admin"));
$root = ORM::factory("item", 1);
$public_album = album::create($root, rand(), "public album");
$public_photo = photo::create($public_album, MODPATH . "gallery/images/gallery.png", "", "");
access::allow(group::everybody(), "view", $public_album);
$root->reload();
// Account for MPTT changes
$private_album = album::create($root, rand(), "private album");
access::deny(group::everybody(), "view", $private_album);
$private_photo = photo::create($private_album, MODPATH . "gallery/images/gallery.png", "", "");
// Make sure that we now have a public photo and private photo.
$this->assert_true(access::group_can(group::everybody(), "view", $public_photo));
$this->assert_false(access::group_can(group::everybody(), "view", $private_photo));
// Swap the photos
item::move($public_photo, $private_album);
$private_album->reload();
// Reload to get new MPTT pointers and cached perms.
$public_album->reload();
$private_photo->reload();
$public_photo->reload();
item::move($private_photo, $public_album);
$private_album->reload();
// Reload to get new MPTT pointers and cached perms.
$public_album->reload();
$private_photo->reload();
$public_photo->reload();
// Make sure that the public_photo is now private, and the private_photo is now public.
$this->assert_false(access::group_can(group::everybody(), "view", $public_photo));
$this->assert_true(access::group_can(group::everybody(), "view", $private_photo));
}
示例10: move_conflicts_result_in_a_rename_test
public function move_conflicts_result_in_a_rename_test()
{
$rand = random::int();
$photo1 = test::random_photo_unsaved(item::root());
$photo1->name = "{$rand}.jpg";
$photo1->slug = (string) $rand;
$photo1->save();
$src_album = test::random_album();
$photo2 = test::random_photo_unsaved($src_album);
$photo2->name = "{$rand}.jpg";
$photo2->slug = (string) $rand;
$photo2->save();
item::move($photo2, item::root());
$this->assert_same(item::root()->id, $photo2->parent_id);
$this->assert_not_same("{$rand}.jpg", $photo2->name);
$this->assert_not_same($rand, $photo2->slug);
}