当前位置: 首页>>代码示例>>PHP>>正文


PHP album::create方法代码示例

本文整理汇总了PHP中album::create方法的典型用法代码示例。如果您正苦于以下问题:PHP album::create方法的具体用法?PHP album::create怎么用?PHP album::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在album的用法示例。


在下文中一共展示了album::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_albums_and_photos

 function add_albums_and_photos($count, $desired_type = null)
 {
     srand(time());
     $parents = ORM::factory("item")->where("type", "album")->find_all()->as_array();
     $owner_id = user::active()->id;
     $test_images = glob(MODPATH . "gallery/tests/images/*.[Jj][Pp][Gg]");
     batch::start();
     $album_count = $photo_count = 0;
     for ($i = 0; $i < $count; $i++) {
         set_time_limit(30);
         $parent = $parents[array_rand($parents)];
         $parent->reload();
         $type = $desired_type;
         if (!$type) {
             $type = rand(0, 10) ? "photo" : "album";
         }
         if ($type == "album") {
             $thumb_size = module::get_var("gallery", "thumb_size");
             $parents[] = album::create($parent, "rnd_" . rand(), "Rnd {$i}", "random album {$i}", $owner_id)->save();
             $album_count++;
         } else {
             $photo_index = rand(0, count($test_images) - 1);
             photo::create($parent, $test_images[$photo_index], basename($test_images[$photo_index]), "rnd_" . rand(), "sample thumb", $owner_id);
             $photo_count++;
         }
     }
     batch::stop();
     if ($photo_count > 0) {
         log::success("content", "(scaffold) Added {$photo_count} photos");
     }
     if ($album_count > 0) {
         log::success("content", "(scaffold) Added {$album_count} albums");
     }
     url::redirect("scaffold");
 }
开发者ID:xafr,项目名称:gallery3,代码行数:35,代码来源:scaffold.php

示例2: resize_url_test

 public function resize_url_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $photo = photo::create($album, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand);
     $this->assert_equal("http://./var/resizes/{$rand}/{$rand}.jpg", $photo->resize_url());
 }
开发者ID:xafr,项目名称:gallery3,代码行数:8,代码来源:Photo_Helper_Test.php

示例3: create_photo_creates_reasonable_slug_test

 public function create_photo_creates_reasonable_slug_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $photo = photo::create($album, MODPATH . "gallery/tests/test.jpg", "This (is) my file%name.jpg", $rand, $rand);
     $this->assert_equal("This-is-my-file-name", $photo->slug);
 }
开发者ID:scarygary,项目名称:gallery3,代码行数:8,代码来源:Photo_Helper_Test.php

示例4: deleting_an_item_deletes_its_comments_too_test

 public function deleting_an_item_deletes_its_comments_too_test()
 {
     $rand = rand();
     $album = album::create(ORM::factory("item", 1), "test_{$rand}", "test_{$rand}");
     $comment = comment::create($album, identity::guest(), "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $album->delete();
     $deleted_comment = ORM::factory("comment", $comment->id);
     $this->assert_false($deleted_comment->loaded);
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:9,代码来源:Comment_Event_Test.php

示例5: add_from_server

 static function add_from_server($task)
 {
     $context = unserialize($task->context);
     try {
         $paths = array_keys(unserialize(module::get_var("server_add", "authorized_paths")));
         $path = $paths[$context["next_path"]];
         if (!empty($context["files"][$path])) {
             $file = $context["files"][$path][$context["position"]];
             $parent = ORM::factory("item", $file["parent_id"]);
             access::required("server_add", $parent);
             access::required("add", $parent);
             if (!$parent->is_album()) {
                 throw new Exception("@todo BAD_ALBUM");
             }
             $name = $file["name"];
             if ($file["type"] == "album") {
                 $album = ORM::factory("item")->where("name", $name)->where("parent_id", $parent->id)->find();
                 if (!$album->loaded) {
                     $album = album::create($parent, $name, $name, null, user::active()->id);
                 }
                 // Now that we have a new album. Go through the remaining files to import and change the
                 // parent_id of any file that has the same relative path as this album's path.
                 $album_path = "{$file['path']}/{$name}";
                 for ($idx = $context["position"] + 1; $idx < count($context["files"][$path]); $idx++) {
                     if (strpos($context["files"][$path][$idx]["path"], $album_path) === 0) {
                         $context["files"][$path][$idx]["parent_id"] = $album->id;
                     }
                 }
             } else {
                 $extension = strtolower(substr(strrchr($name, '.'), 1));
                 $source_path = "{$path}{$file['path']}/{$name}";
                 if (in_array($extension, array("flv", "mp4"))) {
                     $movie = movie::create($parent, $source_path, $name, $name, null, user::active()->id);
                 } else {
                     $photo = photo::create($parent, $source_path, $name, $name, null, user::active()->id);
                 }
             }
             $context["counter"]++;
             if (++$context["position"] >= count($context["files"][$path])) {
                 $context["next_path"]++;
                 $context["position"] = 0;
             }
         } else {
             $context["next_path"]++;
         }
     } catch (Exception $e) {
         $context["errors"][$path] = $e->getMessage();
     }
     $task->context = serialize($context);
     $task->state = "success";
     $task->percent_complete = $context["counter"] / (double) $context["total"] * 100;
     $task->done = $context["counter"] == (double) $context["total"];
 }
开发者ID:xafr,项目名称:gallery3,代码行数:53,代码来源:server_add_task.php

示例6: create_album_silently_trims_trailing_periods_test

 public function create_album_silently_trims_trailing_periods_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     try {
         $album = album::create($root, $rand . "..", $rand, $rand);
     } catch (Exception $e) {
         $this->assert_equal("@todo NAME_CANNOT_END_IN_PERIOD", $e->getMessage());
         return;
     }
     $this->assert_true(false, "Shouldn't create an album with trailing . in the name");
 }
开发者ID:xafr,项目名称:gallery3,代码行数:12,代码来源:Album_Helper_Test.php

示例7: viewable_test

 public function viewable_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $item = self::_create_random_item($album);
     identity::set_active_user(identity::guest());
     // We can see the item when permissions are granted
     access::allow(identity::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
     // We can't see the item when permissions are denied
     access::deny(identity::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
 }
开发者ID:viosca,项目名称:gallery3,代码行数:13,代码来源:Item_Helper_Test.php

示例8: cant_view_comments_for_unviewable_items_test

 public function cant_view_comments_for_unviewable_items_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $comment = comment::create($album, user::guest(), "text", "name", "email", "url");
     user::set_active(user::guest());
     // We can see the comment when permissions are granted on the album
     access::allow(group::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
     // We can't see the comment when permissions are denied on the album
     access::deny(group::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("comment")->viewable()->where("comments.id", $comment->id)->count_all());
 }
开发者ID:Okat,项目名称:gallery3,代码行数:13,代码来源:Comment_Model_Test.php

示例9: _create_album

 private function _create_album($album)
 {
     access::required("edit", $album);
     $form = album::get_add_form($album);
     if ($form->validate()) {
         $new_album = album::create($album, $this->input->post("name"), $this->input->post("title", $this->input->post("name")), $this->input->post("description"), user::active()->id);
         log::success("content", "Created an album", html::anchor("albums/{$new_album->id}", "view album"));
         message::success(t("Created album %album_title", array("album_title" => $new_album->title)));
         print json_encode(array("result" => "success", "location" => url::site("albums/{$new_album->id}"), "resource" => url::site("albums/{$new_album->id}")));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:13,代码来源:albums.php

示例10: setup

 public function setup()
 {
     $this->_server = $_SERVER;
     $root = ORM::factory("item", 1);
     $this->_album = album::create($root, rand(), "test album");
     access::deny(identity::everybody(), "view_full", $this->_album);
     access::deny(identity::registered_users(), "view_full", $this->_album);
     $rand = rand();
     $this->_item = photo::create($this->_album, MODPATH . "gallery/tests/test.jpg", "{$rand}.jpg", $rand, $rand);
     $this->_proxy = ORM::factory("digibug_proxy");
     $this->_proxy->uuid = md5(rand());
     $this->_proxy->item_id = $this->_item->id;
     $this->_proxy->save();
 }
开发者ID:viosca,项目名称:gallery3,代码行数:14,代码来源:Digibug_Controller_Test.php

示例11: change_album_no_csrf_fails_test

 public function change_album_no_csrf_fails_test()
 {
     $controller = new Albums_Controller();
     $root = ORM::factory("item", 1);
     $this->_album = album::create($root, "test", "test", "test");
     $_POST["name"] = "new name";
     $_POST["title"] = "new title";
     $_POST["description"] = "new description";
     access::allow(group::everybody(), "edit", $root);
     try {
         $controller->_update($this->_album);
         $this->assert_true(false, "This should fail");
     } catch (Exception $e) {
         // pass
     }
 }
开发者ID:Okat,项目名称:gallery3,代码行数:16,代码来源:Albums_Controller_Test.php

示例12: move_to_test

 public function move_to_test()
 {
     $root = ORM::factory("item", 1);
     $album1 = album::create($root, "move_to_test_1", "move_to_test_1");
     $album1_1 = album::create($album1, "move_to_test_1_1", "move_to_test_1_1");
     $album1_2 = album::create($album1, "move_to_test_1_2", "move_to_test_1_2");
     $album1_1_1 = album::create($album1_1, "move_to_test_1_1_1", "move_to_test_1_1_1");
     $album1_1_2 = album::create($album1_1, "move_to_test_1_1_2", "move_to_test_1_1_2");
     $album1_2->reload();
     $album1_1_1->reload();
     $album1_1_1->move_to($album1_2);
     $album1_1->reload();
     $album1_2->reload();
     $this->assert_equal(3, $album1_1->right - $album1_1->left);
     $this->assert_equal(3, $album1_2->right - $album1_2->left);
     $this->assert_equal(array($album1_1_2->id => "move_to_test_1_1_2"), $album1_1->children()->select_list());
     $this->assert_equal(array($album1_1_1->id => "move_to_test_1_1_1"), $album1_2->children()->select_list());
 }
开发者ID:xafr,项目名称:gallery3,代码行数:18,代码来源:ORM_MPTT_Test.php

示例13: create_tag_test

 public function create_tag_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $tag1 = "tag1";
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(1, $tag->count);
     // Make sure adding the tag again doesn't increase the count
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(1, $tag->count);
     $rand = rand();
     $album = album::create($root, $rand, $rand, $rand);
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(2, $tag->count);
 }
开发者ID:xafr,项目名称:gallery3,代码行数:19,代码来源:Tag_Test.php

示例14: move_album_test

 public function move_album_test()
 {
     // Create an album with a photo in it
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $photo = ORM::factory("item");
     $photo->name = rand();
     $photo->type = "photo";
     $photo->add_to_parent($album);
     file_put_contents($photo->thumb_path(), "thumb");
     file_put_contents($photo->resize_path(), "resize");
     file_put_contents($photo->file_path(), "file");
     $original_album_name = $album->name;
     $original_photo_name = $photo->name;
     $new_album_name = rand();
     // Now rename the album
     $album->rename($new_album_name)->save();
     $photo->reload();
     // Expected:
     // * the album name changed.
     // * the album dirs are all moved
     // * the photo's paths are all inside the albums paths
     // * the photo files are all still intact and accessible
     $this->assert_equal($new_album_name, $album->name);
     $this->assert_equal($new_album_name, basename($album->file_path()));
     $this->assert_equal($new_album_name, basename(dirname($album->thumb_path())));
     $this->assert_equal($new_album_name, basename(dirname($album->resize_path())));
     $this->assert_same(0, strpos($photo->file_path(), $album->file_path()));
     $this->assert_same(0, strpos($photo->thumb_path(), dirname($album->thumb_path())));
     $this->assert_same(0, strpos($photo->resize_path(), dirname($album->resize_path())));
     $this->assert_equal("thumb", file_get_contents($photo->thumb_path()));
     $this->assert_equal("resize", file_get_contents($photo->resize_path()));
     $this->assert_equal("file", file_get_contents($photo->file_path()));
 }
开发者ID:scarygary,项目名称:gallery3,代码行数:34,代码来源:Item_Model_Test.php

示例15: create

 public function create($parent_id)
 {
     access::verify_csrf();
     $album = ORM::factory("item", $parent_id);
     access::required("view", $album);
     access::required("add", $album);
     $input = Input::instance();
     $form = album::get_add_form($album);
     if ($form->validate()) {
         $new_album = album::create($album, $input->post("name"), $input->post("title", $input->post("name")), $input->post("description"), identity::active_user()->id, $input->post("slug"));
         log::success("content", "Created an album", html::anchor("albums/{$new_album->id}", "view album"));
         message::success(t("Created album %album_title", array("album_title" => html::purify($new_album->title))));
         print json_encode(array("result" => "success", "location" => $new_album->url()));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:viosca,项目名称:gallery3,代码行数:17,代码来源:albums.php


注:本文中的album::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。