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


PHP Image::find_images方法代码示例

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


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

示例1: onPageRequest

 public function onPageRequest($event)
 {
     if ($event->page_matches("sitemap.xml")) {
         $images = Image::find_images(0, 50000, array());
         $this->do_xml($images);
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:7,代码来源:main.php

示例2: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     if ($event->page_matches("rss/images")) {
         $search_terms = $event->get_search_terms();
         $page_number = $event->get_page_number();
         $page_size = $event->get_page_size();
         $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms);
         $this->do_rss($images, $search_terms, $page_number);
     }
 }
开发者ID:JarJak,项目名称:shimmie2,代码行数:10,代码来源:main.php

示例3: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $page, $user;
     if ($event->page_matches("api/shimmie")) {
         $page->set_mode("data");
         $page->set_type("text/plain");
         if ($event->page_matches("api/shimmie/get_tags")) {
             $tag = $event->get_arg(0);
             if (empty($tag) && isset($_GET['tag'])) {
                 $tag = $_GET['tag'];
             }
             $res = $this->api_get_tags($tag);
             $page->set_data(json_encode($res));
         } elseif ($event->page_matches("api/shimmie/get_image")) {
             $arg = $event->get_arg(0);
             if (empty($arg) && isset($_GET['id'])) {
                 $arg = $_GET['id'];
             }
             $image = Image::by_id(int_escape($arg));
             // FIXME: handle null image
             $image->get_tag_array();
             // tag data isn't loaded into the object until necessary
             $safe_image = new _SafeImage($image);
             $page->set_data(json_encode($safe_image));
         } elseif ($event->page_matches("api/shimmie/find_images")) {
             $search_terms = $event->get_search_terms();
             $page_number = $event->get_page_number();
             $page_size = $event->get_page_size();
             $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms);
             $safe_images = array();
             foreach ($images as $image) {
                 $image->get_tag_array();
                 $safe_images[] = new _SafeImage($image);
             }
             $page->set_data(json_encode($safe_images));
         } elseif ($event->page_matches("api/shimmie/get_user")) {
             $query = $user->id;
             $type = "id";
             if ($event->count_args() == 1) {
                 $query = $event->get_arg(0);
                 $type = "name";
             } elseif (isset($_GET['id'])) {
                 $query = $_GET['id'];
             } elseif (isset($_GET['name'])) {
                 $query = $_GET['name'];
                 $type = "name";
             }
             $all = $this->api_get_user($type, $query);
             $page->set_data(json_encode($all));
         } else {
             $page->set_mode("redirect");
             $page->set_redirect(make_link("ext_doc/shimmie_api"));
         }
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:55,代码来源:main.php

示例4: onPageRequest

 public function onPageRequest($event)
 {
     if ($event->page_matches("rss/images")) {
         $page_number = 0;
         $search_terms = array();
         if ($event->count_args() == 1) {
             $page_number = int_escape($event->get_arg(0));
         } else {
             if ($event->count_args() == 2) {
                 $search_terms = explode(' ', $event->get_arg(0));
                 $page_number = int_escape($event->get_arg(1));
             }
         }
         $images = Image::find_images(($page_number - 1) * 10, 10, $search_terms);
         $this->do_rss($images, $search_terms, $page_number);
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:17,代码来源:main.php

示例5: onPageRequest

 public function onPageRequest(PageRequestEvent $event)
 {
     global $database, $page;
     if ($event->page_matches("api/shimmie")) {
         $page->set_mode("data");
         $page->set_type("text/plain");
         if ($event->page_matches("api/shimmie/get_tags")) {
             if ($event->count_args() == 2) {
                 $all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE ?", array($event->get_arg(0) . "%"));
             } else {
                 $all = $database->get_all("SELECT tag FROM tags");
             }
             $res = array();
             foreach ($all as $row) {
                 $res[] = $row["tag"];
             }
             $page->set_data(json_encode($res));
         }
         if ($event->page_matches("api/shimmie/get_image")) {
             $image = Image::by_id(int_escape($event->get_arg(0)));
             $image->get_tag_array();
             // tag data isn't loaded into the object until necessary
             $safe_image = new _SafeImage($image);
             $page->set_data(json_encode($safe_image));
         }
         if ($event->page_matches("api/shimmie/find_images")) {
             $search_terms = $event->get_search_terms();
             $page_number = $event->get_page_number();
             $page_size = $event->get_page_size();
             $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms);
             $safe_images = array();
             foreach ($images as $image) {
                 $image->get_tag_array();
                 $safe_images[] = new _SafeImage($image);
             }
             $page->set_data(json_encode($safe_images));
         }
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:39,代码来源:main.php

示例6: determine_images

 private function determine_images()
 {
     // set vars
     $images_for_removal = array();
     $error = "";
     $min_id = $_POST['remove_id_min'];
     $max_id = $_POST['remove_id_max'];
     $tags = $_POST['remove_tags'];
     // if using id range to remove (comined removal with tags)
     if ($min_id != "" && $max_id != "") {
         // error if values are not correctly entered
         if (!is_numeric($min_id) || !is_numeric($max_id) || intval($max_id) < intval($min_id)) {
             $error = "Values not correctly entered for removal between id.";
         } else {
             // if min & max id are valid
             // Grab the list of images & place it in the removing array
             foreach (Image::find_images(intval($min_id), intval($max_id)) as $image) {
                 array_push($images_for_removal, $image);
             }
         }
     }
     // refine previous results or create results from tags
     if ($tags != "") {
         $tags_arr = explode(" ", $_POST['remove_tags']);
         // Search all images with the specified tags & add to list
         foreach (Image::find_images(1, 2147483647, $tags_arr) as $image) {
             array_push($images_for_removal, $image);
         }
     }
     // if no images were found with the given info
     if (count($images_for_removal) == 0) {
         $error = "No images selected for removal";
     }
     //var_dump($tags_arr);
     return array("error" => $error, "images_for_removal" => $images_for_removal);
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:36,代码来源:main.php

示例7: onPageRequest

 public function onPageRequest($event)
 {
     global $config, $database, $page, $user;
     if ($event->page_matches("post/list")) {
         if (isset($_GET['search'])) {
             $search = url_escape(trim($_GET['search']));
             if (empty($search)) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/list/1"));
             } else {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/list/{$search}/1"));
             }
             return;
         }
         $search_terms = $event->get_search_terms();
         $page_number = $event->get_page_number();
         $page_size = $event->get_page_size();
         try {
             $total_pages = Image::count_pages($search_terms);
             $images = Image::find_images(($page_number - 1) * $page_size, $page_size, $search_terms);
         } catch (SearchTermParseException $stpe) {
             // FIXME: display the error somewhere
             $total_pages = 0;
             $images = array();
         }
         if (count($search_terms) == 0 && count($images) == 0 && $page_number == 1) {
             $this->theme->display_intro($page);
             send_event(new PostListBuildingEvent($search_terms));
         } else {
             if (count($search_terms) > 0 && count($images) == 1 && $page_number == 1) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/view/{$images[0]->id}"));
             } else {
                 send_event(new PostListBuildingEvent($search_terms));
                 $this->theme->set_page($page_number, $total_pages, $search_terms);
                 $this->theme->display_page($page, $images);
             }
         }
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:41,代码来源:main.php

示例8: by_random

 /**
  * Pick a random image out of a set
  *
  * @retval Image
  */
 public static function by_random($tags = array())
 {
     assert(is_array($tags));
     $max = Image::count_images($tags);
     $rand = mt_rand(0, $max - 1);
     $set = Image::find_images($rand, 1, $tags);
     if (count($set) > 0) {
         return $set[0];
     } else {
         return null;
     }
 }
开发者ID:jackrabbitjoey,项目名称:shimmie2,代码行数:17,代码来源:imageboard.pack.php

示例9: mass_tag_edit

 private function mass_tag_edit($search, $replace)
 {
     global $database;
     global $config;
     $search_set = Tag::explode($search);
     $replace_set = Tag::explode($replace);
     $last_id = -1;
     while (true) {
         // make sure we don't look at the same images twice.
         // search returns high-ids first, so we want to look
         // at images with lower IDs than the previous.
         $search_forward = $search_set;
         if ($last_id >= 0) {
             $search_forward[] = "id<{$last_id}";
         }
         $images = Image::find_images(0, 100, $search_forward);
         if (count($images) == 0) {
             break;
         }
         foreach ($images as $image) {
             // remove the search'ed tags
             $before = $image->get_tag_array();
             $after = array();
             foreach ($before as $tag) {
                 if (!in_array($tag, $search_set)) {
                     $after[] = $tag;
                 }
             }
             // add the replace'd tags
             foreach ($replace_set as $tag) {
                 $after[] = $tag;
             }
             $image->set_tags($after);
             $last_id = $image->id;
         }
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:37,代码来源:main.php

示例10: handle_full_sitemap

 private function handle_full_sitemap()
 {
     global $database, $config;
     // add index
     $index = array();
     $index[0] = $config->get_string("front_page");
     $this->add_sitemap_queue($index, "weekly", "1");
     /* --- Add 20 most used tags --- */
     $popular_tags = $database->get_all("SELECT tag, count FROM tags ORDER BY `count` DESC LIMIT 0,20");
     foreach ($popular_tags as $arrayid => $tag) {
         $tag = $tag['tag'];
         $popular_tags[$arrayid] = "post/list/{$tag}/";
     }
     $this->add_sitemap_queue($popular_tags, "monthly", "0.9");
     /* --- Add latest images to sitemap with higher priority --- */
     $latestimages = Image::find_images(0, 50, array());
     $latestimages_urllist = array();
     foreach ($latestimages as $arrayid => $image) {
         // create url from image id's
         $latestimages_urllist[$arrayid] = "post/view/{$image->id}";
     }
     $this->add_sitemap_queue($latestimages_urllist, "monthly", "0.8", date("Y-m-d", strtotime($image->posted)));
     /* --- Add other tags --- */
     $other_tags = $database->get_all("SELECT tag, count FROM tags ORDER BY `count` DESC LIMIT 21,10000000");
     foreach ($other_tags as $arrayid => $tag) {
         $tag = $tag['tag'];
         // create url from tags (tagme ignored)
         if ($tag != "tagme") {
             $other_tags[$arrayid] = "post/list/{$tag}/";
         }
     }
     $this->add_sitemap_queue($other_tags, "monthly", "0.7");
     /* --- Add all other images to sitemap with lower priority --- */
     $otherimages = Image::find_images(51, 10000000, array());
     foreach ($otherimages as $arrayid => $image) {
         // create url from image id's
         $otherimages[$arrayid] = "post/view/{$image->id}";
     }
     $this->add_sitemap_queue($otherimages, "monthly", "0.6", date("Y-m-d", strtotime($image->posted)));
     /* --- Display page --- */
     // when sitemap is ok, display it from the file
     $this->generate_display_sitemap();
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:43,代码来源:main.php

示例11: by_random

 /**
  * Pick a random image out of a set.
  *
  * @param string[] $tags
  * @return Image
  */
 public static function by_random($tags = array())
 {
     assert('is_array($tags)');
     $max = Image::count_images($tags);
     if ($max < 1) {
         return null;
     }
     // From Issue #22 - opened by HungryFeline on May 30, 2011.
     $rand = mt_rand(0, $max - 1);
     $set = Image::find_images($rand, 1, $tags);
     if (count($set) > 0) {
         return $set[0];
     } else {
         return null;
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:22,代码来源:imageboard.pack.php

示例12: delete_by_query

 private function delete_by_query($query)
 {
     global $page, $user;
     assert(strlen($query) > 1);
     foreach (Image::find_images(0, 1000000, Tag::explode($query)) as $image) {
         send_event(new ImageDeletionEvent($image));
     }
 }
开发者ID:nsuan,项目名称:shimmie2,代码行数:8,代码来源:main.php

示例13: api_find_posts

 /**
  * find_posts()
  * Find all posts that match the search criteria. Posts will be ordered by id descending.
  *
  * Parameters:
  * - md5: md5 hash to search for (comma delimited)
  * - id: id to search for (comma delimited)
  * - tags: what tags to search for
  * - limit: limit
  * - page: page number
  * - after_id: limit results to posts added after this id
  *
  * @return string
  * @throws SCoreException
  */
 private function api_find_posts()
 {
     $results = array();
     $this->authenticate_user();
     $start = 0;
     if (isset($_GET['md5'])) {
         $md5list = explode(",", $_GET['md5']);
         foreach ($md5list as $md5) {
             $results[] = Image::by_hash($md5);
         }
         $count = count($results);
     } elseif (isset($_GET['id'])) {
         $idlist = explode(",", $_GET['id']);
         foreach ($idlist as $id) {
             $results[] = Image::by_id($id);
         }
         $count = count($results);
     } else {
         $limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100;
         // Calculate start offset.
         if (isset($_GET['page'])) {
             // Danbooru API uses 'page' >= 1
             $start = (int_escape($_GET['page']) - 1) * $limit;
         } else {
             if (isset($_GET['pid'])) {
                 // Gelbooru API uses 'pid' >= 0
                 $start = int_escape($_GET['pid']) * $limit;
             } else {
                 $start = 0;
             }
         }
         $tags = isset($_GET['tags']) ? Tag::explode($_GET['tags']) : array();
         $count = Image::count_images($tags);
         $results = Image::find_images(max($start, 0), min($limit, 100), $tags);
     }
     // Now we have the array $results filled with Image objects
     // Let's display them
     $xml = "<posts count=\"{$count}\" offset=\"{$start}\">\n";
     foreach ($results as $img) {
         // Sanity check to see if $img is really an image object
         // If it isn't (e.g. someone requested an invalid md5 or id), break out of the this
         if (!is_object($img)) {
             continue;
         }
         $taglist = $img->get_tag_list();
         $owner = $img->get_owner();
         $previewsize = get_thumbnail_size($img->width, $img->height);
         $xml .= xml_tag("post", array("id" => $img->id, "md5" => $img->hash, "file_name" => $img->filename, "file_url" => $img->get_image_link(), "height" => $img->height, "width" => $img->width, "preview_url" => $img->get_thumb_link(), "preview_height" => $previewsize[1], "preview_width" => $previewsize[0], "rating" => "u", "date" => $img->posted, "is_warehoused" => false, "tags" => $taglist, "source" => $img->source, "score" => 0, "author" => $owner->name));
     }
     $xml .= "</posts>";
     return $xml;
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:67,代码来源:main.php

示例14: delete_by_query

 private function delete_by_query()
 {
     global $page;
     $query = $_POST['query'];
     $reason = @$_POST['reason'];
     assert(strlen($query) > 1);
     log_warning("admin", "Mass deleting: {$query}");
     $count = 0;
     foreach (Image::find_images(0, 1000000, Tag::explode($query)) as $image) {
         if ($reason && class_exists("ImageBan")) {
             send_event(new AddImageHashBanEvent($image->hash, $reason));
         }
         send_event(new ImageDeletionEvent($image));
         $count++;
     }
     log_debug("admin", "Deleted {$count} images", true);
     $page->set_mode("redirect");
     $page->set_redirect(make_link("post/list"));
     return false;
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:20,代码来源:main.php

示例15: api_danbooru


//.........这里部分代码省略.........
         } else {
             header("HTTP/1.0 409 Conflict");
             header("X-Danbooru-Errors: authentication error");
             return;
         }
     }
     /*
     find_posts()
     Find all posts that match the search criteria. Posts will be ordered by id descending.
     Parameters
     * md5: md5 hash to search for (comma delimited)
     * id: id to search for (comma delimited)
     * tags: what tags to search for
     * limit: limit
     * offset: offset
     * after_id: limit results to posts added after this id
     */
     if ($event->get_arg(1) == 'find_posts' || $event->get_arg(1) == 'post' && $event->get_arg(2) == 'index.xml') {
         $this->authenticate_user();
         if (isset($_GET['md5'])) {
             $md5list = explode(",", $_GET['md5']);
             foreach ($md5list as $md5) {
                 $results[] = Image::by_hash($md5);
             }
         } elseif (isset($_GET['id'])) {
             $idlist = explode(",", $_GET['id']);
             foreach ($idlist as $id) {
                 $results[] = Image::by_id($id);
             }
         } else {
             $limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100;
             $start = isset($_GET['offset']) ? int_escape($_GET['offset']) : 0;
             $tags = isset($_GET['tags']) ? Tag::explode($_GET['tags']) : array();
             $results = Image::find_images($start, $limit, $tags);
         }
         // Now we have the array $results filled with Image objects
         // Let's display them
         $xml = "<posts>\n";
         foreach ($results as $img) {
             // Sanity check to see if $img is really an image object
             // If it isn't (e.g. someone requested an invalid md5 or id), break out of the this
             if (!is_object($img)) {
                 continue;
             }
             $taglist = $img->get_tag_list();
             $owner = $img->get_owner();
             $xml .= "<post md5=\"{$img->hash}\" rating=\"Questionable\" date=\"{$img->posted}\" is_warehoused=\"false\" file_name=\"{$img->filename}\" tags=\"" . $this->xmlspecialchars($taglist) . "\" source=\"" . $this->xmlspecialchars($img->source) . "\" score=\"0\" id=\"{$img->id}\" author=\"{$owner->name}\"/>\n";
         }
         $xml .= "</posts>";
         $page->set_data($xml);
     }
     /*
     find_tags() Find all tags that match the search criteria.
     Parameters
     * id: A comma delimited list of tag id numbers.
     * name: A comma delimited list of tag names.
     * tags: any typical tag query. See Tag#parse_query for details.
     * after_id: limit results to tags with an id number after after_id. Useful if you only want to refresh
     */
     if ($event->get_arg(1) == 'find_tags') {
         if (isset($_GET['id'])) {
             $idlist = explode(",", $_GET['id']);
             foreach ($idlist as $id) {
                 $sqlresult = $database->execute("SELECT id,tag,count FROM tags WHERE id = ?", array($id));
                 if (!$sqlresult->EOF) {
                     $results[] = array($sqlresult->fields['count'], $sqlresult->fields['tag'], $sqlresult->fields['id']);
开发者ID:kmcasto,项目名称:shimmie2,代码行数:67,代码来源:main.php


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